0

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'

Jonnyboi
  • 505
  • 5
  • 19
  • 1
    Does this answer your question? [String formatting: % vs. .format vs. f-string literal](https://stackoverflow.com/questions/5082452/string-formatting-vs-format-vs-f-string-literal) – gmdev Sep 27 '21 at 15:22

1 Answers1

2

you forgot the f for formatting

url = (rf"C:\Users\{userid}\Report - {monthyear}.xlsx")
xplo4d
  • 264
  • 1
  • 6