元组定义
元组的元素不能修改
name = ("laowang","laoli")
拆包
name = ("laowang","laoli")
name1,name2 = name #name1的值为laowang,name2的值为老李
与字典结合使用
info = {"name":"laowang","name2":"laoli"}
for A,B in info.items:
print("A=%s,B=%s"%(A,B))
元组的元素不能修改
name = ("laowang","laoli")
name = ("laowang","laoli")
name1,name2 = name #name1的值为laowang,name2的值为老李
与字典结合使用
info = {"name":"laowang","name2":"laoli"}
for A,B in info.items:
print("A=%s,B=%s"%(A,B))
本文标题:Python基础语法(五)元组
本文链接:https://www.haomeiwen.com/subject/zhpmgxtx.html
网友评论