【argv】对文件的读取read
作者:互联网
# 导入argv
from sys import argv script, filename = argv # 打开文件 txt = open(filename) print("Here's your file %r" % filename) # 打印出文件内容 print(txt.read())
cmd窗口:
python test.py start.txt #(test.py为脚本文件,start.txt为读取的文件)
结果如下:
标签:文件,读取,read,py,argv,filename,print,txt 来源: https://www.cnblogs.com/sdr900/p/16361713.html