Python格式化字符串

2021-08-17  本文已影响0人  术枚派

Python的字符串可以使用%来进行格式化。


a = "hello"
print("%s"%a)
#输出:hello

字符串中有多个格式化字符,后面需要用括号来传参数

a = "hello"
b = "world"
print("%s%s"%(a,b))
上一篇 下一篇

猜你喜欢

热点阅读