python百分号是什么
来源:魅力女性吧 1.8W
python中%:
1、 求模运算,相当于mod,也就是计算除法的余数,比如5%2就得到1。
2、 %还用在python的格式化输出,比如:
a = 'test'
print 'it is a %s' %(a)
打印的结果就是 it is a test
python中%:
1、 求模运算,相当于mod,也就是计算除法的余数,比如5%2就得到1。
2、 %还用在python的格式化输出,比如:
a = 'test'
print 'it is a %s' %(a)
打印的结果就是 it is a test