Jonnyboi
Jonnyboi

Reputation: 557

Python, Variable not passing in String

I am trying to pass some variables into my string. However when I run this, i literally get userid and monthyear

code: url = (r"C:\Users\{userid}\Report - {monthyear}.xlsx")

Returns: FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\{userid}\\Report - {monthyear}.xlsx'

Upvotes: 0

Views: 54

Answers (1)

xplo4d
xplo4d

Reputation: 260

you forgot the f for formatting

url = (rf"C:\Users\{userid}\Report - {monthyear}.xlsx")

Upvotes: 2

Related Questions