0

New coder here. I'm trying to make code that'll add itself to startup for a class, but I'm having this issue where the quotes won't end where they're supposed to so I can add the current user in. I've tried the other method with %s, same quote issue, but at the end. I've also tried using /, and adding an extra space, but I'm making it for windows and those throw an error. Please help!

import getpass  
import os 
loca="C:\Users\" + getpass.getuser() + "\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\"
os.chdir(loca)

Thank you!

  • \ in python is an escape character. So you are escaping the `"` You either need to use r-strings `r'this\is\a\string'` or escape the \ `'this\\is\\a\\string'` – It_is_Chris Sep 29 '21 at 13:04

0 Answers0