python用%来处理字符串

%s 可以字符串拼接
msg='i am %s my hobby is %s' % ('lhf','alex')
print(msg)
执行结果:
i am lhf my hobby is alex

%s 可以按收任何类型( 数字对应字符串);也可以接收列表;

%d:只接收数字

'%.2f' % float_var: 保留两位小数(此时处理完仍为字符串类型)

https://www.cnblogs.com/nulige/p/6115793.html

新战场:https://blog.csdn.net/Stephen___Qin
原文地址:https://www.cnblogs.com/Stephen-Qin/p/10266692.html