I want to use System variables to access certain directories without hardcoding the path.
Im Running Python 3.7 on a Windows 10 64 bit machine. The whole idea is, to later acess some executable files that exist in the desired directory.
import os
path = r'%homepath%/Desktop'
dirlist = os.listdir(path)
print(dirlist)
I expect the output to be a list of files on the desktop. What i get is an error message saying that the specified directory cannot be found. If i use the explizit path things work out just fine.
No comments:
Post a Comment