Python:Environment variables: Difference between revisions

From wiki
Jump to navigation Jump to search
Created page with "<syntaxhighlight lang=python> import os import subprocess env = os.environ.copy() for var in env: print(var,env[var] </syntaxhighlight> ToDo: check where this commes in..."
 
No edit summary
 
Line 1: Line 1:
;Show environment variables
<syntaxhighlight lang=python>
<syntaxhighlight lang=python>
import os
import os
import subprocess
import subprocess


env = os.environ.copy()
for var, value in os.environ.items():
for var in env:
     print(var, value)
     print(var,env[var]
</syntaxhighlight>
</syntaxhighlight>


ToDo:
ToDo:


check where this commes in handy:
check where this comes in handy:
  subprocess.Popen(my_command, env=my_env)
  subprocess.Popen(my_command, env=my_env)

Latest revision as of 18:42, 3 July 2024

Show environment variables
import os
import subprocess

for var, value in os.environ.items():
    print(var, value)

ToDo:

check where this comes in handy:

subprocess.Popen(my_command, env=my_env)