python語法規範
阿新 • • 發佈:2020-10-18
在python shell 中輸入 import this
可以看到python之禪
The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those!
官網中的PEP8標準
詳細的預防規範
官網路徑:Documentation——Developer’s Guide——PEP 8
PEP 8 -- Style Guide for Python Code
pycharm配置autopep8
配置後,自動格式化程式碼
安裝 autopep8
cmd視窗輸入:pip install autopep8
在Pycharm中安裝autopep8配置
配置專案
- Name:Autopep8(可以隨便取)
- Tools settings
Programs:autopep8
Arguments:--in-place --aggressive --aggressive \(FilePath\)
Working directory:\(ProjectFileDir\)
點選Output Files→新增,在對話方塊中的:Regular expression to match output中輸入:\(FILE_PATH\):\(LINE\):\(COLUMN\):.*
https://blog.csdn.net/weixin_43968663/article/details/100903559