无法使IPython读取shell变量

Léo*_* 준영 2 ipython

我在IPython中运行命令

cd $cs<TAB>
Run Code Online (Sandbox Code Playgroud)

但它不允许我扩展路径.

如何让IPython读取shell变量?

Chr*_*heD 5

如果我正确理解你的'shell变量'是什么意思.如果你的意思是在shell中设置变量('环境变量'):你可以用os.environ读取它们...

import os
cs = os.environ.get('cs')
runstring = "cd %s" (cs)
...
Run Code Online (Sandbox Code Playgroud)