【发布时间】:2014-07-17 21:56:37
【问题描述】:
$ python
Python 2.7.3 (default, Apr 10 2013, 05:46:21)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> c = open("/home/aditya/Documents/in.txt","r+")
>>> c.read()
'GNU and python are amazing.\n'
>>> c.write("Oh yes they are!")
>>> c.read()
''
>>> c.close()
>>>
aditya@aditya-Latitude-D620:~$
我在课程中了解到“r+”可以用于读写。但是,在我 write() 之后,我无法阅读它。 read() 方法返回一个空值。为什么会这样?
【问题讨论】:
标签: python python-2.7 file-io io