有个关于open()的疑问:能否以嵌套的方式以不同模式打开同一个文档,例如:
with open(file,'r') as myfile1:
for eachline in myfile1:
with open(file,'a') as myfile2:
myfile2.write(eachline)
...全文
3874打赏收藏
Python2.7中open函数打开问题
有个关于open()的疑问:能否以嵌套的方式以不同模式打开同一个文档,例如: with open(file,'r') as myfile1: for eachline in myfile1: with open(file,'a') as myfile2: myfile2.write(eachline)