[英]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.