使用
-c(command) 参数(假设您的文件名为
foo.py):
$ python -c 'import foo; print foo.hello()'
或者,如果您不关心名称空间污染,请执行以下操作:
$ python -c 'from foo import *; print hello()'
和中间立场:
$ python -c 'from foo import hello; print hello()'

使用
-c(command) 参数(假设您的文件名为
foo.py):
$ python -c 'import foo; print foo.hello()'
或者,如果您不关心名称空间污染,请执行以下操作:
$ python -c 'from foo import *; print hello()'
和中间立场:
$ python -c 'from foo import hello; print hello()'