我想使用环境变量中的值。我把它放在
~/.bashrc
我和file能够在新的shell和当前的shell中看到这些(显然,在
source
它)。但是,当我在python3 shell中导入相同的变量(在现有的和新的shell中)时,返回的值总是
None
.
我读了很多书,发现
relatable answer
但它没有解决我的问题,或者说,我无法理解它。
我的bashrc文件是:
SLACK_URL="https://hooks.slack.com/"
我可以在终端中看到值,但在python shell中看不到:
ubuntu@ip-A.B.C.D:~$ echo $SLACK_URL
https://hooks.slack.com/
ubuntu@ip-A.B.C.D:~$ python3
Python 3.6.8 (default, Jan 14 2019, 11:02:34)
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.getenv('SLACK_URL')
>>>
我希望看到实际变量的值,但是我得到了
没有
.