1..format()
a='world'
b='Tom'
'hello{},i am {}'.format(a,b)
这篇文章讲得很详细Python - “{ }“.format( ) 格式化的多种方法
2.使用f-string
格式化
a='world'
b='Tom'
f"hello {a},i am {b}"
.format()
a='world'
b='Tom'
'hello{},i am {}'.format(a,b)
这篇文章讲得很详细Python - “{ }“.format( ) 格式化的多种方法
f-string
格式化a='world'
b='Tom'
f"hello {a},i am {b}"