2017-12-08 1 views
-2
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 파일 작업을 배우고 있습니다. 위 코드가 제대로 작동하지 않습니다. 파일을 읽지 않습니다.화면에 출력이 없습니다. 파일을 읽을 때 출력이 나오지 않습니다.

+1

'name.read (0)'이라고 읽은 데이터의 양은 어느 정도입니까? 0의 주장이 무엇이라고 생각하십니까? –

+0

나는 그것을 얻었다 ... 그것은 name.read() 또는 name.read (-1)이어야한다. 처음부터 모든 문서를 읽으려면. 고맙습니다. –

답변

0

0string = name.read(0)에서 제거하면 모두 표시되거나 0보다 큰 숫자를 쓸 수 있습니다. 길이가 표시되어야합니다.

관련 문제