# 列表转集合 去重
list1 = [1, 2, 3, 4, 3]
print(set(list1))
# 两个列表转字典
list2 = ["1", "2"]
list3 = [1, 2]
print(dict(zip(list2, list3)))
# 嵌套列表转字典
list4 = [["1", 1], ["2", 2]]
print(dict(list4))
# 列表 元组 转字符串
list5 = ["1", "2", "3"]
print("".join(list5))
# 字典key 和 value互换
dict6 = {"a": 1, "b": 2}
print({value: key for key, value in dict6.items()})
#输出*********
{1, 2, 3, 4}
{'1': 1, '2': 2}
{'1': 1, '2': 2}
123
{1: 'a', 2: 'b'}
05-30
917
05-27
452
02-05
1914
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交