字符串format函数使用
#format拼接字符串,format()内的参数必须为可迭代的对象
p1="i am {2},age {1},{0}".format("seven",18,'alex') print(tp1) tp1="i am {1},age {1}".format("seven",18,'alex')#按照元祖下标取值 print(tp1) tp1="i am {name},age {age},really {name}".format(name="tang",age=20)#按照字典键去取值,name为字典键名 print(tp1) tp1="i am {name},age {age},really {name}".format(**{"name":"seven","age":18})#**按照字典键去取值,name为字典键名 print(tp1) print( help(format) )
如果我失败了,至少我尝试过,不会因为痛失机会而后悔