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

前端 未结 2 681
孤街浪徒
孤街浪徒 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']
    
    0 讨论(0)
  • 2020-12-29 01:33

    Just

    del os.environ['MYVAR']
    

    should work.

    0 讨论(0)
提交回复
热议问题