My *.py script has some non-ASCII characters in comment lines and when I run it I am getting the following warning:

sys:1: DeprecationWarning: Non-ASCII character '\xe5' in file /Users/haitran/Documents/Sophomore UCB/Python/ on line 118, but no encoding declared; see for details

The thing is I went to the indicated page and fixed my script by putting:
# -*- coding: <utf-8> -*-
on the second line and I'm still getting the warning. The script runs, but the warning is annoying and I don't understand what I need to do to make it stop coming up. What am I doing wrong?

Thanks in advance.

Recommended Answers

All 2 Replies

Could be your editor/IDE.
Also, a Unicode string literal is preceded with a 'u'.

Haha it was a really basic mistake. There are no <> signs. e.g.

# -*- coding: utf-8 -*-
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.