pythonshell显示了一个包含内容的文件,但它们不能加载到dis上

2024-09-30 20:26:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用脚本写入文件。我知道:

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()

但是当我从它的位置加载文件时,它是完全空白的。是什么可能导致这种令人费解的行为?谢谢

科迪


Tags: 文件intxthomemodescriptsusernameopen