【问题标题】:how to load python script in interactive shell如何在交互式shell中加载python脚本
【发布时间】:2015-05-06 22:00:28
【问题描述】:

我正在尝试 sudo python get_gps.py -c 并希望它加载脚本,然后呈现交互式 shell 以实时调试脚本,而不是手动输入。

【问题讨论】:

    标签: python


    【解决方案1】:

    来自文档:

    $ python --help
    usage: /usr/bin/python2.7 [option] ... [-c cmd | -m mod | file | -] [arg] ...
    Options and arguments (and corresponding environment variables):
    -B     : don't write .py[co] files on import; also PYTHONDONTWRITEBYTECODE=x
    -c cmd : program passed in as string (terminates option list)
    -d     : debug output from parser; also PYTHONDEBUG=x
    -E     : ignore PYTHON* environment variables (such as PYTHONPATH)
    -h     : print this help message and exit (also --help)
    -i     : inspect interactively after running script; forces a prompt even
             if stdin does not appear to be a terminal; also PYTHONINSPECT=x
    

    使用-i 选项

    【讨论】:

    • 重要的是要指出 -i 必须立即跟随 python。它不能在脚本名称之后。
    猜你喜欢
    • 2016-05-29
    • 2011-08-31
    • 2017-02-13
    • 2013-06-19
    • 1970-01-01
    • 1970-01-01
    • 2019-09-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多