Backslash error SyntaxError: EOL while scanning string literal

Question:

I want to use a backslash in Python, but I always get an error. This is my code

fileName = "file"
linkName = "rep" + file_name
print(linkName)

The error:
SyntaxError: EOL while scanning string literal

Asked By: Niku

||

Answers:

The error is simple. Just had the same
Use this:

fileName = "file"
linkName = "rep" + chr(92) + file_name
print(linkName)

chr(92) stands for

Answered By: user15244524
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.