【发布时间】:2014-11-02 19:32:27
【问题描述】:
我有一个 bash 脚本和一个 python 脚本:
脚本
#!/bin/bash
a=10
export a
python script.py
script.py
# access 'a' somehow
有没有办法从 python 访问exported 变量?
【问题讨论】:
标签: python bash inheritance export
我有一个 bash 脚本和一个 python 脚本:
脚本
#!/bin/bash
a=10
export a
python script.py
script.py
# access 'a' somehow
有没有办法从 python 访问exported 变量?
【问题讨论】:
标签: python bash inheritance export
导出的变量设置为环境变量。使用os.environ(字典)在您的 Python 脚本中阅读这些内容:
import os
a = os.environ['a']
【讨论】: