嗨,我试图理解这一点:
因此,此“ file.txt”的输出如下:我如何使其看起来像这样:
现在看起来像:eatdogcatrat
想: 吃 狗 ..基本上需要使每个内容都移到下一行。
my_locations = open("file.txt" , "w")
for mylist in channel:
print(mylist)
my_locations.write(mylist)
my_locations.close()
答案 0 :(得分:0)
希望这会起作用!
channel = ['eat', 'dog', 'cat', 'rat']
my_locations = open("file.txt", "w")
for mylist in channel:
print(mylist)
my_locations.write(mylist + '\n') # to have each go to the next line.
my_locations.close()