© 1999-2048 dssz.net 粤ICP备11031372号
[其它] Python基本类型的连接组合和互相转换方式(13种)
说明:本篇总结了一下字符串,列表,字典,元组的连接组合使用和类型的互相转换小例子,尤其列表中的extend()方法和字典中的 update方法非常的常用。 1.连接两个字符串 a = "hello " b = "world" a += b print(a) # hello world 2.字典的连接 dict1 = {1: "a", 2: "b"} dict2 = {3: "c", 4: "d"} dict1.update(dict2) print(dict1) # {1: 'a', 2: 'b<weixin_38680664> 上传 | 大小:80kb