You're looking for os.environ
, which is a dictionary-like object representing the environment variables available to your program.
import os
os.environ['JWD'] = variablename
But, as noted in the comments, if your expectation is that this affect the shell that's running the Python code, it still won't work. Your Python program is a separate process and gets its own environment variables (which may be inherited from the shell but will not modify them back upstream). See this answer to a similar question for a more detailed explanation, but the summary is: If you want to mess with the shell's state, write a shell script, not a Python script.