Python printf的使用方法

发布时间:2019-08-31 10:12:23编辑:auto阅读(3215)

    age = 4
    name = ‘hmm’
    print(‘my name is ‘,name,’age is ‘,age) #第一种方法。
    my name is hmm age is 4
    print(‘my name is %s, age is %s’ %(name,age))#第一种方法。
    my name is hmm, age is 4
    print(‘my name is {0} age is {1}’.format(name,age))#第一种方法。
    my name is hmm age is 4

关键字