I would like to write the file path with an windows environment variable for the windows username but I don't know how to write it correctly. I would like to use an env variable because I use the script on different computers.
Here is the code:
import os
os_username = os.environ.get('USERNAME')
workbook = xlsxwriter.Workbook(r"C:\Users\" + os_username + r"\Google-Drive\filename.xlsx")
The above code does not work to find the correct path. The code for finding the username is working. The file path would be for instance: C:\Users\Peter\Google-Drive\filename.xlsx