Web development based on hi-nginx (python) -- UTF-8 coding, hi-nginxutf-8

Source: Internet
Author: User

Web development based on hi-nginx (python) -- UTF-8 coding, hi-nginxutf-8

It is very important to use UTF-8 encoding in a consistent manner. This is especially true for python2.

If you are using python2 in hi-nginx and you need to use Chinese text such as Japan, Korea, and so on without any difficulty, do not forget to use it:

#-*-Coding: UTF-8 -*-

At the same time, any template file should also be UTF-8 encoded. In this way, we can avoid many unnecessary errors.

 

When the hi. py framework is introduced, the system automatically checks the default encoding of the sys module and sets it to UTF-8 encoding:

If sys. version_info.major <3: reload (sys) sys. setdefaultencoding ('utf-8 ')

 

Therefore, when using the hi. py framework, remember that everything is attributed to UTF-8.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.