"Write applications quickly in Java, {}, Python, {}. ".format('python','R')
'Write applications quickly in Java, python, Python, R. '
for age in range(0,5):
year=1990+age
print ("In {},you are {} years old".format(year+10,age))
In 2000,you are 0 years old
In 2001,you are 1 years old
In 2002,you are 2 years old
In 2003,you are 3 years old
In 2004,you are 4 years old
the keyword arguments
'{name},{year}'.format(name='weiyudang',year=18)
'weiyudang,18'
通过对象属性
classPerson:def__init__(self,name,age):
self.name=name
self.age=age
def__str__(self):return"This guy is {self.name},is {self.age} old ".format(self=self)
print (Person('weiyudang',18))
format using method#location"{0},{1}".format('weiyudang',23)'weiyudang,23'"I love you ,{},{}".format('weiyudang',18)'I love you ,weiyudang,18'"Write applications quickly in Java, {}, Python, {}.