-1

i want to insert variables date and month inside string

filename = f'C:\Users\91956\Desktop\{date}{month}.csv.zip'

i get error

                                                           ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

i think the string need to be a raw string i.e i need to write r' before string but by doing so i am unable to insert variables in string

how to do this?

Akshad Patil
  • 47
  • 1
  • 6

1 Answers1

0

It’s about the backslashes. You need to escape every one of them for this work.

filename = f'C:\\Users\\91956\\Desktop\\{date}{month}.csv.zip'
rudolfovic
  • 3,163
  • 2
  • 14
  • 38