2017-06-23 135 views
-3
from sys import argv 

from os.path import exists 

print "Look what I can do" 

script,This_file,That_file,=argv 

print "I'm gonna paste this into that" 

Whatever=open(That_file) 

Whatevers = That_file.read() 

"So That_file is %d bytes long"%len(Whatever) 

"Do the input and output files exist?"% exists(This_file,That_file) 

Huh=open(That_file) 

Huh.write(Whatever) 

    AttributeError: 'str' object has no attribute 'read' 
+0

好吧,我是比較新的這個網站,所以請原諒question.I不同尋常的外觀希望大家仍然可以幫助我。我只是想創建一個將內容從一個.txt粘貼到另一個的程序。 – b1lal555

+0

您無法讀取字符串,您可以讀取文件。 'That_file'是一個字符串,'Whatever'是一個文件。 >>'Whatever.read()' – Julien

+0

你的問題是什麼?白線導致錯誤?爲什麼你的代碼加倍間隔?請使用更多描述性變量名稱。 –

回答

0

是:

Whatever=open(That_file) 
Whatevers = Whatever.read() 
+0

謝謝,它現在有效! – b1lal555

相關問題