-1
import sys
fileobject=open('file.txt','w')
fileobject.write(sys.stdin.readline())
Cat
在上面的代碼中,執行後不應該在文件中嗎?但是,當我運行它時,我發現文件爲空。如果我的代碼有誤,有人可以解釋sys.stdin.read()
和sys.stdout.write()
是如何工作和使用的嗎?Python文件處理:標準輸入輸出