【发布时间】:2015-03-23 03:45:39
【问题描述】:
在 python 2.7 中我能够做到:
file('text.txt', 'w').write('some text')
但是在 python 3 中我必须使用 open 函数,所以我不能再在一行上写入文件了。
f = open('text.txt', 'w')
print('some text', file = f)
f.close()
他们为什么要删除file 函数?
【问题讨论】:
标签: python file python-3.x deprecated