Reputation: 323
I am trying execute following lines of code in python3.4:
user ="ŠŒŽ‡†ƒ€‰"
print(user)
But the above user initialization line is resulting in following error:
SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0x8a in position 0: invalid start byte
I want to use the same user in authentication later. How to use UTF-8 characters in python3.4 script ?
Upvotes: 0
Views: 222
Reputation: 57520
Your file is not actually saved in UTF-8. Assuming that the syntax error is occurring on the first non-ASCII character (Š
), the file is most likely encoded in Windows 1252, which encodes that character as 0x8A. If you wish to continue using this encoding, add this line to the top of your Python file:
# -*- coding: windows-1252 -*-
Upvotes: 4