%运算符(求余符)也可用于字符串格式化。给定'string' % values,则string中的%实例会以零个或多个values元素替换。此操作被称为字符串插值,示例如下:
>>> import math
>>> print('The value of pi is approximately %5.3f.' % math.pi)
The value of pi is approximately 3.142.
客服热线:0731-85127885
违法和不良信息举报
举报电话:0731-85127885 举报邮箱:tousu@csai.cn
优草派 版权所有 © 2024