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 @   xgqfrms  阅读(21)  评论(1编辑  收藏  举报
相关博文:
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
历史上的今天:
2021-08-17 Apple Watch Series 6 开启自带 GPS All In One
2021-08-17 element-ui & async-validator bug All In One
2021-08-17 element-ui & multi tabs bug All In One
2020-08-17 LeetCode & linked list
2020-08-17 how to install GitLab on Raspberry Pi OS
2020-08-17 UML online tools
2020-08-17 React Hooks 内部实现原理
点击右上角即可分享
微信分享提示