Python 自動化運維3-Print輸
- 2020 年 1 月 10 日
- 筆記
Python語言之Print輸出方法
Print 輸出方法: '-' 表示左對齊 '+' 表示正號 '0' 表示用0填充 'f' 前指定一個最小寬度 '.' 指定小數點後的精度 格式:% [flag][width][.precision]typecode 方法1: 1.num = 7.9 print 'the num is %f' % num 2.num = 7.9 num2 = 10 print 'the num is %f and %d' % (num,num2) 3.num = 7.9 num2 = 10 print 'the num is %f and %d' % (num,3) 方法2: 4.num = 7.9 num2 = 10 print 'the nums is {0} and {1} . format{num,num2} 方法3: lang = "python" print "I love %(program)s" % {"program": lang}


