python-字符串格式化

Posted 逆鳞

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python-字符串格式化相关的知识,希望对你有一定的参考价值。

python中字符串拼接除了用‘+’还可以用%s占位符。

1 import datetime
2 today = datetime.date.today()
3 username = input(请输入用户名:).strip()
4 welcome = 欢迎光临:%s 今天日期是:%s%(username,today)
5 print(welcome)

 

以上是关于python-字符串格式化的主要内容,如果未能解决你的问题,请参考以下文章