What is the correct way to unset a linux environment variable in python?

前端 未结 2 680
孤街浪徒
孤街浪徒 2020-12-29 01:02

From the documentation:

If the platform supports the unsetenv() function, you can delete items in this mapping to unset environment varia

2条回答
  •  醉梦人生
    2020-12-29 01:17

    You can still delete items from the mapping, but it will not really delete the variable from the environment if unsetenv() is not available.

    del os.environ['MYVAR']
    

提交回复
热议问题