【发布时间】:2013-06-03 08:28:49
【问题描述】:
Learning Python the Hard Way 中的练习 15 是关于开始使用两种方法在脚本中读取的文件:
- 通过 argv 和
- 通过 raw_input。
这是脚本:
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()
作者提出了一些问题。第五个是想办法:
why one method of getting the filename is better than the other.
我想知道使用其中一种是否有真正的优势。
【问题讨论】:
标签: python python-2.7