定义源码编码 (Source Encoding),sourceencoding,# -*- coding
文章由Byrx.net分享于2019-03-23 08:03:56
定义源码编码 (Source Encoding),sourceencoding,# -*- coding
# -*- coding: utf-8 -*-# (From http://www.python.org/dev/peps/pep-0263/ )# Python has a syntax to declare the encoding of# a Python source file. The encoding information is then used by the# Python parser to interpret the file using the given encoding. Most# notably this enhances the interpretation of Unicode literals in# the source code and makes it possible to write Unicode literals# using e.g. UTF-8 directly in an Unicode aware editor# Python will default to ASCII as standard encoding if no other# encoding hints are given.# To define a source code encoding, a magic comment must# be placed into the source files either as first or second# line in the file. This example sets the source code encoding to# \"utf-8\".import chilkat # The source code encoding only applies to how Python parses# your script source. # Python string variables are nothing more than null-terminated bytes. # The Python language does not try to interpret the bytes according to # a character encoding.# # Chilkat objects are capable of accepting either ANSI or utf-8 encoded strings,# and can return ANSI or utf-8 strings.# Each Chilkat object has a \"Utf8\" property that controls whether arguments and# return values are utf-8 or ANSI.# For example:# create a new email object.email = chilkat.CkEmail()# indicate that input/output strings should be utf-8email.put_Utf8(True)# set the email subject to a utf-8 string literal.email.put_Subject(\'èéêë\')# REMEMBER: When editing Python source code, make sure you save your source file# using the character encoding specified by the \"magic comment\".print \"Done!\"#该片段来自于http://byrx.net
相关内容
- 通过python post提交数据的代码演示,pythonpost,# -*- codin
- 用python实现发送即时消息到twitter,pythontwitter,Python语言
- python获取远程图片的大小和尺寸,,#!/usr/bin/e
- python 发邮件抄送,暗送(cc,bcc)代码,pythonbcc,pytho
- python发邮件例子,python发邮件,来自python官方的例
- python官方示例发送带附件邮件,python官方示例附件,下面
- python发送html格式邮件,python发送html,#!/usr/bin/e
- BeautifulSoup解析人人好友状态,beautifulsoup解析,#!/usr/bi
- 定时关机神器,定时关机神,有了它,你以后再也不为深
- 简单SVM分类器的开源实现,核心代码150行,svm150行,一个
评论关闭