Skip to content
Advertisement

$ variable name in Python to get os.getenv

My curl.trill works:

$ = os.getenv('$')

cookies = {
    'AlteonP': f"AKgyK+bV+AqyP5hdVrxVFA{$}",
    'JSESSIONID': '919BAF7B84FEF902E41306B1C27345E8.lgd',
}

But python throws this error:

  $ = os.getenv('$')
  File "<stdin>", line 1
  $ = os.getenv('$')
    ^
  SyntaxError: invalid syntax

I have tried changing $ to something else but it didn’t help. Any suggestions?

Advertisement

Answer

you can use $ as the name of a variable, try this code:

import os
  
key = 'HOME'
value = os.getenv(key)
print("Value of 'HOME' environment variable :", value) 
  

key = '$'
value = os.getenv(key)
print("Value of '$' environment variable :", value) 
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement