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

Python 元组解构 All In One

Python 元组解构 All In One

#!/usr/bin/python3

# 中间值解构赋值

a, b, c, d, *e, f, g = range(20)
print(len(e))
# 14
a, b, *c, d = [1, 2, 3, 4, 5, 6, 7, 8, 9]
print(a)
print(b)
print(c)
print(d)

'''
1
2
[3, 4, 5, 6, 7, 8]
9

'''

https://www.sololearn.com/compiler-playground/chuI1m2O13uL

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment

Tuple / 元组

Python 的元组与列表类似,不同之处在于元组的元素不能修改。

元组使用小括号 ( ),列表使用方括号 [ ]

元组创建很简单,只需要在括号中添加元素,并使用逗号隔开即可。

image

https://www.runoob.com/python3/python3-tuple.html

comment / 注释

# 这是一个单行注释


'''
这是多行注释,用三个单引号
这是多行注释,用三个单引号 
这是多行注释,用三个单引号
'''

"""
这是多行注释,用三个双引号
这是多行注释,用三个双引号 
这是多行注释,用三个双引号
"""

https://www.runoob.com/python3/python3-comment.html

(🐞 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!

refs

https://www.sololearn.com/learning/1158/4674/11990/2



©xgqfrms 2012-2021

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

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


posted @ 2023-03-28 01:02  xgqfrms  阅读(53)  评论(1编辑  收藏  举报