import time
name = open('list.txt','a+')
print ("When file was opened the pointer was at", name.tell())
name.write('It\'s all about mindset.')
time.sleep(2)
print ("Writing your script.... Wait for some time...")
name.close()
name = open('list.txt','r')
string = name.read(0)
print('Final output is:'`
print (string)
name.close()
我目前正在学习python文件操作。上面的代码无法正常工作。它没有读取文件。
答案 0 :(得分:0)
只需从0
移除string = name.read(0)
即可显示全部或写入大于0
的数字。
应该显示字符的长度。