xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

Python & PEP 8 & Style Guide All In One

Python & PEP 8 & Style Guide All In One

PEP 8 – Style Guide for Code

https://peps.python.org/pep-0008/

'单引号' vs "双引号"

https://peps.python.org/pep-0008/#string-quotes

在 Python 中,单引号字符串和双引号字符串是一样的。本 PEP 不对此提出建议。选择一个规则并坚持下去。

选择一个规则并坚持下去。但是,当字符串包含单引号或双引号字符时,请使用另一个字符以避免字符串中出现反斜杠。它提高了可读性。

对于三引号字符串,始终使用双引号字符以与 PEP 257 中的文档字符串约定保持一致。


#!/usr/bin/python3
__author__ = 'xgqfrms'

# coding: utf-8

print('Python 3 🐍🐍🐍')

print("Python 3 🐍")

# 单行注释

"""

多行注释(双引号)

"""

'''

多行注释(单引号)

'''

semicolon ;

不需要分号, 使用缩进控制 ✅

Python3 Template & vscode code snippets All In One

https://github.com/xgqfrms/vscode/blob/master/code-snippets/py3.json

https://github.com/xgqfrms/vscode/blob/master/code-snippets/python.json

如何在 Python 中使用 UTF-8 编码 All In One

https://www.cnblogs.com/xgqfrms/p/5745802.html

Python 3.x

Python UTF-8 encode

Python 3.x

#!/usr/bin/python3
__author__ = 'xgqfrms'

# coding=utf-8

#!/usr/bin/python3
__author__ = 'xgqfrms'

# coding: utf-8

Python 2.x

#!/usr/bin/python2
__author__ = 'xgqfrms'

# -*- coding: utf-8 -*-

#!/usr/bin/python2
__author__ = 'xgqfrms'

# -*- coding: UTF-8 -*-


refs

https://github.com/xgqfrms/Python/issues/17

https://www.python.org/



©xgqfrms 2012-2020

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2022-08-17 17:11  xgqfrms  阅读(18)  评论(1编辑  收藏  举报