How to use export with Python on Linux

后端 未结 12 1546
梦如初夏
梦如初夏 2020-11-29 23:09

I need to make an export like this in Python :

# export MY_DATA=\"my_export\"

I\'ve tried to do :

# -*- python-mode -*-
# -         


        
12条回答
  •  情话喂你
    2020-11-29 23:26

    Kind of a hack because it's not really python doing anything special here, but if you run the export command in the same sub-shell, you will probably get the result you want.

    import os
    
    cmd = "export MY_DATA='1234'; echo $MY_DATA" # or whatever command
    os.system(cmd)
    

提交回复
热议问题