Python: iterate through two lists and write them to outfile on the same line

前端 未结 3 1664
时光说笑
时光说笑 2021-01-24 21:33

I would like to iterate through two lists simultaneously and write each item from both lists, tab-separated on the same line.

word = [\'run\', \'windless\', \'ma         


        
3条回答
  •  渐次进展
    2021-01-24 21:37

    I think you're on the right path. You just need to give the write() function a single line to write.

    Like this:

    for w, p in zip(word, pron):
        outfile.write("%s, %s" % (w, p))
    

提交回复
热议问题