不太确定该如何表达,但是我正在将bash脚本转换为python,并且试图在python库中调用方法,该方法通常是通过CLI调用的。该方法使用argparse并在调用时需要2个参数。
我不确定如何从单独的python脚本调用此方法并提供两个参数。
我尝试过的
>> from somelibrary import mymethod as method
>> method.main('foo', 'bar')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: main() takes 0 positional arguments
but 2 were given
>>> method.main()
usage: [-h] foo bar
: error: the following arguments are required:
foo, bar
任何帮助是极大的赞赏!
相关分类