(1)format使用花括号{}进行渲染前的参数引用声明,花括号里面可以
缺省、
引用参数的序号、
引用变量名。
(2)
print('{} is a {}'.format('marry','boy')) #输出marry is a boy
print('{1} is a {0}'.format('marry','boy')) #输出boy is a marry
print('{name} is a {gender}'.format(name='marry',gender='boy')) #输出marry is a boy
(3)
a=input('The city you want to go is ')
print("The {}'s temperature is hot".format(a) )
#输出The city you want to go is,输入城市名jinan后,输出:The jinan's temperature is hot
(2)
print('{} is a {}'.format('marry','boy')) #输出marry is a boy
print('{1} is a {0}'.format('marry','boy')) #输出boy is a marry
print('{name} is a {gender}'.format(name='marry',gender='boy')) #输出marry is a boy
(3)
a=input('The city you want to go is ')
print("The {}'s temperature is hot".format(a) )
#输出The city you want to go is,输入城市名jinan后,输出:The jinan's temperature is hot
#input函数是让用户输入信息的函数