Python set Linux environment variable and execute Linux commands

Python export Linux environment variable

os.environ['OS_AUTH_URL']='https://openstack.com:5000/v3'
os.environ['OS_PROJECT_NAME']="admin"
os.environ['OS_USER_DOMAIN_NAME']="Default"
os.environ['OS_USERNAME']="admin"
os.environ['OS_PASSWORD']="admin"
os.environ['OS_REGION_NAME']="nova"
os.environ['OS_INTERFACE']="public"
os.environ['OS_IDENTITY_API_VERSION']='3'

Python execute Linux commands and get return value

result = os.popen('openstack server list --project {} | wc -l'.format(project))
result = resulte.strip()

For the crontab, it needs to add the path to the environment

os.environ['PATH']='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin'