1 year ago

#362077

test-img

RomanWASD

Python: How can I define a path to folder with variable in path

i want to use this code to Remove the Bookmarks file to replace it with another file later on.

i use.

import getpass
user = getpass.getuser()

to get the user name and then i want to use.

os.remove(r"C:\Users\xy\AppData\Local\Google\Chrome\User Data\Default\Bookmarks")

But i can't figure out how to replace the xy with the variable use. I have tried to work with %s but without success.

I'd like to do it in Python because it's part of a larger project I'm working on.

python

variables

filepath

0 Answers

Your Answer

Accepted video resources