zshuangyan / blog

我的个人博客
2 stars 0 forks source link

谷歌Python代码规范 #29

Open zshuangyan opened 5 years ago

zshuangyan commented 5 years ago
  1. 一般只导入包或模块,尽量避免导入单个的类或者函数,避免对本地的命名空间 惯例:
    
    # 导入包或者模块
    import x

从包中导入模块

from x import y

如果模块名过长,可以使用别名

from x import y as z

别名尽量用标准

import y as z (e.g., np for numpy).



2. 注释