一编码转换
unicode 可以编译成 UTF-U GBK
即

#!/usr/bin/env python
# _*_ coding:utf-8 _*_
__author__ = 'Administrator'
a='方' #默认是utf-8
a_unicod=a.decode('utf-8') # decode是解码成unicode 括号是脚本内容的默认编码 即:将脚本内容的utf-8解码成unicode
a_gbk=a_unicod.encode('gbk') #encode是编码,将unicode的编码内容编码成指定的,这里是gbk
print(a_gbk) #用于终端打印
#print(u"方") #3里面是字符串 2里面是unicode
# 3版本直接将utf-8编码成GBK 不需要先转成unicode了,因为3没有了
E:py_tests2_py>python3 test.py
Traceback (most recent call last):
File "test.py", line 6, in <module>
a_unicod=a.decode('utf-8') # decode是解码成unicode 括号是脚本内容的默认编码 即:将脚本内容的utf-8解码成unicode
AttributeError: 'str' object has no attribute 'decode'

四 pycharm 安装 配置
file-setings-editor- file && file encode template 输入
#!/usr/bin/env python # _*_ coding:utf-8 _*_ __author__ = 'superfang'
五 pycharm 快捷键
ctrl+/ 批量注释
shift+方向键 选中
shift+tab 向左tab
