python 中文编码

#!/usr/bin/python
#-*- coding:utf-8 -*-    ###python推荐使用这种
'''#coding=utf-8'''      ###这种也可以,比较简洁

print '中国'

备注:python3 可以自动识别中文,无需加这句话

##########打印三角形################

#!/usr/bin/python
#-*- coding:utf-8 -*-

i = 1

while i<=5:
    j = 1
    while j<=i:
        print '*',    ===》等价于 print("*",end = "")
        j+=1
    print ''
    i+=1
原文地址:https://www.cnblogs.com/shanhua-fu/p/7640164.html