我试图解决Zed Shaw s Learnshed 艰难之路的15个额外信贷问题,但我已陷入了一个问题。 该法典如下:
from sys import argv
script, filename = argv
txt = open(filename)
print "Here s your file %r:" % filename
print txt.read()
print "I ll also ask you to type it again:"
file_again = raw_input("> ")
txt_again = open(file_again)
print txt_again.read()
print txt_again.read()
I understand all the code that has been used, but extra credit question 7 asks:
开始<代码>python,并迅速使用
open
。 通知您如何打开档案和操作read
?
I ve tried inputting everything I could think of in terminal (on a mac) after first starting up python with the python command, but I can t get the code to run. What should I be doing to get this piece of code to run from the prompt?