日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)Python教程:python怎么讓數(shù)字右對齊?

python中使用format()方法格式化數(shù)字設(shè)置右對齊:< (默認(rèn))左對齊、> 右對齊、^ 中間對齊、= (只用于數(shù)字)在小數(shù)點后進(jìn)行補齊

>>> print('{} and {}'.format('hello','world'))  # 默認(rèn)左對齊

 hello and world

>>> print('{:10s} and {:>10s}'.format('hello','world'))  # 取10位左對齊,取10位右對齊

hello      and      world

>>> print('{:^10s} and {:^10s}'.format('hello','world'))  # 取10位中間對齊

hello    and   world  

>>> print('{} is {:.2f}'.format(1.123,1.123))  # 取2位小數(shù)

1.123 is 1.12

>>> print('{0} is {0:>10.2f}'.format(1.123))  # 取2位小數(shù),右對齊,取10位

1.123 is       1.12


當(dāng)前題目:創(chuàng)新互聯(lián)Python教程:python怎么讓數(shù)字右對齊?
新聞來源:http://www.dlmjj.cn/article/dhjpdgd.html