标签:travel ids print orm code strong ted 多个 pop
将元组作为一个记录存入列表中:
traveler_ids=[(‘USA‘,‘311‘),(‘BRA‘,‘342‘),(‘ESP‘,‘566‘)] for passport in sorted(traveler_ids): print("%s%s"%passport)
元组拆包:
city,year,pop,chg,area=(‘Tokyo‘,2003,32450,0.66,8014)
一行话实现多个变量的赋值。
嵌套元组拆包:
metro_areas=[ (‘Tokyo‘,‘JP‘,(35.6,120.9)), (‘New York‘,‘US‘,(40.8,-75)), ] fmt=‘{:15} | {:9f} | {:9f}‘ for name,cc,(lat,lon) in metro_areas: print(fmt.format(name,lat,lon))
标签:travel ids print orm code strong ted 多个 pop
原文地址:https://www.cnblogs.com/liuguangshou123/p/13303037.html