在pycharm上依次选择打开 File->settings->Editor->File andCode Templates->Python Script

python2.X版本中需要设置编码格式为utf-8

#!/usr/bin/env python
# encoding: utf-8  
  
""" 
@author: roc
@contact: roc@csdn.com 
@software: ${PRODUCT_NAME} 
@file: ${NAME}.py 
@create: ${DATE} ${TIME} 
"""  

或者

# -*- coding: utf-8 -*-
""" 
@author: roc
@contact: roc@csdn.com 
@software: ${PRODUCT_NAME} 
@file: ${NAME}.py 
@create: ${DATE} ${TIME} 
@Project : ${PROJECT_NAME}
"""  

 

  1. def func():  
  2.     pass  
  3.   
  4. class main():  
  5.     def __init__(self):  
  6.         pass  
  7.   
  8. if __name__ == "__main__":  
  9.     pass  
Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐