Python Forum
How to get %appdata% directory? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How to get %appdata% directory? (/thread-31982.html)



How to get %appdata% directory? - Oshadha - Jan-13-2021

I tried to get %appdata% directory,
But failed.

Script,
import os
print os.getenv('APPDATA')
Error:
File "C:\Users\User\AppData\Local\Temp\atom_script_tempfiles\db861f50-55af-11eb-b27a-c3d006aa3aaa", line 4 print os.getenv('APPDATA') ^ SyntaxError: invalid syntax
Im trying to save a cache file in %appdata% directory!


RE: How to get %appdata% directory? - Oshadha - Jan-13-2021

Owhh,
import os

direc =  os.getenv('APPDATA')
print(direc)
Py 2 and py 3 is different!