file_object = open(r"/root/py_test/web01/src/ftime",'rw')
try:
print file_object.read()
file_object.write('test')
finally:
file_object.close( )
读取一个文件,内容就一行
然后再写入,报错。
IOError
IOError: [Errno 9] Bad file descriptor
什么情况呢?
阿神2017-04-18 10:34:46
Your python version should be 2.X, right? Please try changing 'rw' in the permissions section to 'r+'
PHP中文网2017-04-18 10:34:46
rw cannot be recognized. If you want to have both read and write permissions, you can change it to ab+