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.')

  

原文地址:https://www.cnblogs.com/jiaxinwei/p/11623725.html