例如,可以从命令行运行
method1
$ python -c 'import hello; hello.method1()'
或
method2
:
$ python -c 'import hello; hello.method2(somearg,someotherarg)'
这需要在以下目录中运行命令
hello.py
是,或
在蟒蛇城。
允许灵活性,您可以调整字符串,并根据需要使用任何有效的参数运行任何有效方法。
有关详细信息,请查看
how to run functions from the command line