python3 列表转 元组
list2 = [2,w]tuple2 = tuple(list2)
python3 元组转 字典
tuple2 = ((2, “w”),(3, “e”))
dict2 = dict(tuple2)
或dict2 = dict((y, x) for x, y in tuple2)
元组x、y调换位置后转字典
ASCII码与字符的相互转换
ord()将ASCII字符转换为对应的数值
s="hello world"
for i in s:
print(ord(i),end=" ")
# 104 101 108 108 111 32 119 111 114 108 100
ord('A')
# 65
chr()将数值转换为对应的ASCII字符
chr(65)
# 'A'