我正在尝试使用脚本写入文件。我知道:
In [15]: f = file('/home/me/scripts/python/notrecent.txt', 'w')
In [16]: f
Out[16]: <open file '/home/me/scripts/python/notrecent.txt', mode 'w' at 0x7f8677440030>
In [17]: notrecentstring
Out[17]: 'Username, "Full name", "Clinics they still work at", "Last logon"\n"jdo", "John Do", "Dallas", "08/19/2013"\n"
...yadayada'
In [18]: f.flush()
In [19]: f.write(notrecentstring)
In [20]: f
Out[20]: <open file '/home/me/scripts/python/notrecent.txt', mode 'w' at 0x7f8677440030>
In [22]: f.close()
In [23]: f = file('/home/me/scripts/python/notrecent.txt', 'r')
In [24]: content = f.read()
In [25]: content
Out[25]: 'Username, "Full name", "Clinics they still work at", "Last logon"\n"jdo", "John Do", "Dallas", "08/19/2013"\n"
...yadayada'
In [26]: f.close()
但是当我从它的位置加载文件时,它是完全空白的。是什么可能导致这种令人费解的行为?谢谢
科迪
目前没有回答
相关问题 更多 >
编程相关推荐