Advertisement
steve-shambles-2109

Get environment variables

Mar 28th, 2020
472
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. """Code snippets vol-47-snippet-233
  2.   Get environment variables
  3.  
  4. Download all snippets so far:
  5. https://wp.me/Pa5TU8-1yg
  6.  
  7. Blog: stevepython.wordpress.com
  8.  
  9. Requirements: None.
  10.  
  11. Origin:
  12. Steve Shambles March 2020
  13. """
  14. import os
  15.  
  16. # Display some example environment variables.
  17. print(os.getenv('USERNAME'))
  18. print(os.getenv('HOME'))
  19. print(os.getenv('COMPUTERNAME'))
  20. print(os.getenv('PROCESSOR_IDENTIFIER'))
  21. print(os.getenv('PROCESSOR_ARCHITECTURE'))
  22. print(os.getenv('OS'))
  23.  
  24. # Note these examples are Windows vars,
  25. # except HOME, which is used on Linux too.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement