不太確定該如何表達,但是我正在將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任何幫助是極大的贊賞!
如何調用需要CLI參數的python方法?
慕的地6264312
2021-04-28 14:11:48
