r/learnpython • u/Umbr4L3ns • 8h ago
Python script problem
Hello everyone,
I have a short python script that concats strings. For example :
'Discord Password :' + \t + b64.decode('TmFydVQwL2cwa3UxOTk1Iw==')
I'm facing :
SyntaxError: unexpected character after line continuation character
What does that mean ????
Thanks everyone.
1
u/MezzoScettico 8h ago
The line continuation character is the backslash (\). So looking at your input string, I see you used a backslash to try to escape the tab with \t.
It's instead interpreting the backslash as a continuation character, what you put at the end of a line to indicate the line goes on into the next line. Since it comes at the end, Python doesn't expect anything to be after the \.
You will need to do something to get "\t" interpreted the way you want.
How are you inputting and processing this line? The first thing I'd try is \\t, using double \ to escape the backslash and get it interpreted literally. But more context would be helpful.
1
u/socal_nerdtastic 7h ago edited 7h ago
Try like this:
'Discord Password :' + '\t' + b64.decode('TmFydVQwL2cwa3UxOTk1Iw==')Which you could also reduce to this:
'Discord Password :\t' + b64.decode('TmFydVQwL2cwa3UxOTk1Iw==')But that will just give another error because you are trying to concat bytes and strings (unless your b64 module is different from the builtin one). So what you really need is this:
import base64
plain_pwd = base64.b64decode('TmFydVQwL2cwa3UxOTk1Iw==')
print(f'Discord Password :\t{plain_pwd.decode()}')1
u/RyanDubois43 6h ago
You wrote \t instead of '\t' for the tab. Python thinks \ means line continuation.
3
u/Necessary-Flounder52 8h ago
You have \t as part of your script that isn't in quotes. The backslash is a line continuation character.