python学习日记--argv


在pycharm运行下面的代码
from sys import argv

script,filename = argv
#先打开文件
txt = open (filename)
print ("Here's your file %r:" % filename)
#读取文件内容
print (txt.read())
txt.close()

报错内容:
解决方法:
1.alt+shift+F10调出运行窗口,之后选择Edit Configurations或者按0

或者

2.输入参数

再次运行,就没有报错

 
 
 

猜你喜欢

转载自www.cnblogs.com/pp-zz/p/9549829.html