Python 3.x 学习笔记

 字符集编码

 

    Python 2.x 默认字符集 ASCII
    Python 3.x 默认字符集 utf-8

 

  指定字符集两种方式:

 

    # -*- coding:utf-8 -*-
    # coding:utf-8

 

 变量设置规范(建议):

 

    变量:全小写,用下划线分词。

    常量:全大写,用下划线分词。

      例如:

  

 

 

 字符串:

  • 自然字符串, 通过在字符串前加r或R。 如 r"this is a line with \n" 则\n会显示,并不是换行。
  • python允许处理unicode字符串,加前缀u或U, 如 u"this is an unicode string"。

 

posted @ 2017-05-26 17:33  将-臣  阅读(204)  评论(0编辑  收藏  举报