1. 程式人生 > >python中%代表什麼意思?

python中%代表什麼意思?

python中%:

1. 求模運算,相當於mod,也就是計算除法的餘數,比如5%2就得到1。

2. %還用在python的格式化輸出,比如:
     a = 'test'
     print 'it is a %s' %(a)
     列印的結果就是 it is a test