无法访问环境变量值?

时间:2020-10-12 07:27:34

标签: python environment-variables

来自此How to access environment variable values?

我已经尝试过

import os
print(os.environ['HOME'])

这是我遇到的错误

> Traceback (most recent call last):
  File "d:/TOD/iot/paint/OStest.py", line 2, in <module>
    print(os.environ['HOME'])
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\os.py", line 675, in __getitem__
    raise KeyError(key) from None
KeyError: 'HOME'
PS D:\TOD\iot\paint>

仅供参考。几个月前,我的环境变量出现了问题。 我认为这会引起问题

0 个答案:

没有答案