如何在 PyCharm 中设置 Python 代码模板
#!/usr/bin/env python-- coding: utf-8 --Created by iFantastic on $DATEif name == ‘main’:pass复制代码设置 File > Settings > File and Code Template > Python Script使用模板时,$DATE 会自动替换为当前日期。第
·
#!/usr/bin/env python
-- coding: utf-8 --
Created by iFantastic on $DATE
if name == ‘main’:
pass
复制代码
设置 File > Settings > File and Code Template > Python Script
使用模板时,$DATE 会自动替换为当前日期。
第一行代码,用于指定运行脚本时默认的 Python 解释器。
if name == ‘main’ 我们简单的理解就是: 如果模块是被直接运行的,则代码块被运行,如果模块是被导入的,则代码块不被运行。
pass:占位语句,空语句,是为了保持程序结构的完整性。
更多推荐
已为社区贡献1条内容
所有评论(0)