简体   繁体   中英

Django SyntaxError at / Non-ASCII character '\xe6' in file

I am getting this error:

SyntaxError at /
Non-ASCII character '\xe6' in file

pointed to my forms.py file which has some chinese characters

I have to put # -*- coding: utf-8 -*- at the start the forms.py file before it would work

I thought Django handles everything in unicode? What's wrong?

Nothing is wrong. You have done the correct thing. If you want to use non-ASCII characters in your code, you need to tell Python what encoding you are using.

This has nothing to do with Django, or Unicode.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM