from sys import argv
script, filename = argv
txt = open(filename)
print ("Here's your file %r:" % filename)
print (txt.read())
print ("Type the filename again:")
file_again = input("> ")
txt_again = open(file_again)
print (txt_again.read())
open(filename)就是打开文件命令 filename填写文件路径(路径中不要出现中文)
print (txt.read()) 打印读取的内容
![](https://img.haomeiwen.com/i5125879/c637941922f0d9b7.png)
网友评论