Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Python
  3. Question
Python

Working with UTF-8 encoding in Python source

Asked by Emily Coleman Apr 13, 2021 2.1K views 1 answer
Share

About this question

Consider:

$ cat bla.py

u = unicode('d…')

s = u.encode('utf-8')

print s

$ python bla.py

File "bla.py", line 1

SyntaxError: Non-ASCII character 'xe2' in file bla.py on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

How can I declare python coding UTF-8 strings in the source code?

Your answer

1 Answer

More Python discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Python Blogs

Guides, tips and career advice on Python from JanBask experts.