[英]run python script from command line and then enter interactive mode
Is there a way to run a python module from command line ( -m option, which imports and runs a module ), and then enter the interactive mode? 有没有办法从命令行运行python模块(-m选项,导入并运行模块),然后进入交互模式?
I need something similar to "cmd /k command". 我需要类似“cmd / k命令”的东西。
I tested the -i option, but it didn't work; 我测试了-i选项,但它没有用; I'm not sure but it seems just redirects in_stream from input. 我不确定,但似乎只是从输入重定向in_stream。
You need to put the -i
before the -m
. 你需要在-m
之前放置-i
。
The -m
option is an interface option; -m
选项是一个接口选项; it terminates the option list and all subsequent arguments will end up in sys.argv
for the module's main
function. 它终止了选项列表,所有后续参数将以sys.argv
结尾,用于模块的main
函数。 ( link to doc ) ( 链接到doc )
或者进入交互模式并运行你的python文件:
import <filename>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.