作者:佩菱淑华7 | 来源:互联网 | 2023-06-08 15:31
Ihaveafunctionthatprocessesfilecontents,butrightnowIhavethefilenamehardcodedinthef
I have a function that processes file contents, but right now I have the filename hardcoded in the function like this as a keyword argument:
我有一个处理文件内容的函数,但是现在我把文件名硬编码在这个函数中,就像一个关键字参数:
def myFirstFunc(filename = open('myNotes.txt', 'r')):
pass
#and I call it like this:
myFirstFunc()
I would like to treat the argument as a filename, and process the contents.
我想把这个参数当作文件名,并处理内容。
- how do i modify the statement above-I tried this:
filename= sys.argv[1]# or is it 0?
- 我如何修改上面的语句:filename= sys。argv[1]#还是0?
- how do I call it?
- 我怎么称呼它?
Please help with basic Python (Just learning)
请帮助使用基本的Python(学习)
Thanks
谢谢
3 个解决方案