Life is short I use Python - 8
2020-12-13 06:25
标签:长度 jin 分配 序号 span 有序 col short min 聊一聊Python中的序列 第一步,先看看下面的代码,有序序列 第二步,判断序列中有无某元素 第三步,获取序列长度 第四步,取最值 Life is short I use Python - 8 标签:长度 jin 分配 序号 span 有序 col short min 原文地址:https://www.cnblogs.com/tabjin/p/11178960.html# 在Python中,str、list、tuple都是序列,是有顺序的,其中元素按照序号分配
>>> "hell,tabjin"[1]
‘e‘
>>> [1,2,3][1]
2
>>> (1,2,3)[1]
2
>>> 5 in [1,2,3,4,5] # 判断在
True
>>> 8 in [1,2,3,4,5]
False
>>> 5 not in [1,2,3,4,5] # 判断不在
False
>>> 8 not in [1,2,3,4,5]
True
>>> len("hell,tabjin")
11
>>> len([1,2,3,4,5])
5
>>> len((1,2,3,4,5))
5
>>> max([1,2,3,4,5])
5
>>> min([1,2,3,4,5])
1
>>> max("hell,tabjin")
‘t‘
>>> min("hell,tabjin")
‘,‘
>>> ord(‘t‘)
116
>>> ord(‘j‘)
106
>>> ord(‘ ‘)
32
下一篇:WindowState笔记
文章标题:Life is short I use Python - 8
文章链接:http://soscw.com/essay/32985.html