[英]Python formatted literal string and thousand separator
有沒有一種方法可以將python3.6格式的文字字符串( PEP498 )與格式規范結合在一起?
print('Count: {:,}'.format(count)) # Count: 10,000
print(f'Count: {count}') # Count: 10000
我能想到的最接近的東西是使用像這樣的format
函數:
print(f'Count: {format(count, "6,d")}') # Count: 10,000 # can use "6,d" or any other format that puts thousands separators
這是最好的方法嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.