python format使用方法

#使用format 方法进行格式化
print("The number {1:} in hex is: {1:#x}, the number {0:} in oct is {0:o}".format(5555,55))
print("my name is {name},my age is {age},and my QQ is {qq}".format(name = "Dong Fuguo",age = 40 , qq = "30646****"))
#格式化的字符串常量
name = "Dong"
age = 39
print(f'My name is {name}, and I am {age} years old.')

  

posted @ 2019-10-04 23:50  从前有座山,山上  阅读(350)  评论(0编辑  收藏  举报