ZhangZhihui's Blog  

 

 

>>> format_string=("%2f" %13.333222)
>>> print(format_string)
13.333222
>>> format_string=("%2.3f" %13.333222)
>>> print(format_string)
13.333

 

>>> name = "AAA"
>>> age = 5
>>> '%s is %d years old.' % (name, age)
'AAA is 5 years old.'
>>> "{} is {} years old.".format(name, age)
'AAA is 5 years old.'
>>> f'{name} is {age} years old.'
'AAA is 5 years old.'

 

posted on 2024-06-17 19:33  ZhangZhihuiAAA  阅读(3)  评论(0编辑  收藏  举报