1.普通的輸出:
print(str)#str是任意一個字符串,數字···
2.格式化輸出:
print('1,2,%s,%d'%('asd',4)) 1,2,asd,4
與C語言有點類似
3.其它:
>>> pi = 3.141592653 >>> print('%10.3f' % pi) #字段寬10,精度3 3.142 >>> print("pi = %.*f" % (3,pi)) #用*從后面的元組中讀取字段寬度或精度 pi = 3.142 >>> print('%010.3f' % pi) #用0填充空白 000003.142 >>> print('%-10.3f' % pi) #左對齊 3.142 >>> print('%+f' % pi) #顯示正負號 +3.141593
想詳細了解請看:https://www.cnblogs.com/graceting/p/3875438.html