有没有办法将python3.6格式的文本字符串(PEP498)与format specifications结合起来
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
这是最好的方法吗
从link you gave:
以你为例:
相关问题 更多 >
编程相关推荐