【问题标题】:Unable to make IPython to read shell variables无法让 IPython 读取 shell 变量
【发布时间】:2009-05-10 19:14:02
【问题描述】:

我在 IPython 中运行命令

cd $cs<TAB>

但它不允许我扩展路径。

如何让 IPython 读取 shell 变量?

【问题讨论】:

    标签: ipython


    【解决方案1】:

    如果我正确理解您所说的“shell 变量”是什么意思。如果您的意思是在 shell 中设置的变量(“环境变量”):您可以使用 os.environ...

    import os
    cs = os.environ.get('cs')
    runstring = "cd %s" (cs)
    ...
    

    【讨论】:

    • 在现代版本的 IPython 中你也可以cs = !echo $cs; runstring = "cd %s" % (cs[0])
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-03
    • 2019-11-21
    • 2020-08-02
    • 1970-01-01
    • 2014-01-06
    • 1970-01-01
    相关资源
    最近更新 更多