1. 程式人生 > >如何在 PyCharm 中設置 Python 代碼模板

如何在 PyCharm 中設置 Python 代碼模板

microsoft 替換 color rip /usr set 導入 strong mic

#!/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__‘ 我們簡單的理解就是: 如果模塊是被直接運行的,則代碼塊被運行,如果模塊是被導入的,則代碼塊不被運行

如何在 PyCharm 中設置 Python 代碼模板