gkd
python内置函数
t_dict = {"a":"z",
"b":"y",
"c":"x"
}
print(max(t_dict)) # c
print(min(t_dict)) # a
切片
# 字符串可切片
# 列表可切片
# 元组可切片
# 字典不可切片,因为字典没有索引值的概念
print([0,1,2,3,4][1:3]) # [1, 2]
print((0,1,2,3,4)[1:3]) # (1,2)
运算符
# 字符串可切片
# 列表可切片
# 元组可切片
# 字典不可切片
print([0,1,2,3,4][1:3]) # [1, 2]
print((0,1,2,3,4)[1:3]) # (1,2)
# 拼接
# 字符串、列表、元组
# + 不修改原来的字符串……
print("a"+'b') # ab
print((1,2)+(3,4)) # (1, 2, 3, 4)
print([1,2]+[3,4]) # [1, 2, 3, 4]
# expand 将l修改了
l=[1,2]
l.extend([3,4,5])
print(l)
# [1, 2, 3, 4, 5]
# 增加元素
l1 = [1, 2, 3, 4, 5]
l1.append(9)
print(l1) # [1, 2, 3, 4, 5, 9]
l1.append([6, 7])
print(l1) # [1, 2, 3, 4, 5, 9, [6, 7]]