我目前正在爲學校編寫代碼,並且在我關閉它後重新打開文件時出現問題。如何在寫入中打開文件,關閉它,然後在讀取中重新打開它?
test=open('test.txt','w')
.......
test.close
retest=open('test.txt','r')
這是確切的錯誤消息我得到:
TypeError: invalid file: <_io.TextIOWrapper name='test.txt'
mode='w' encoding='cp1252'>