>> "{:,}".format(56381779049.1) '56,381,779,049.1'..." />
发布时间:2019-09-05 07:01:30编辑:auto阅读(3140)
法1:
>>> "{:,}".format(56381779049)
'56,381,779,049'
>>> "{:,}".format(56381779049.1)
'56,381,779,049.1'
>>>
>>> import re
>>> subject = '1234567'
>>> result = re.sub(r"(?<=\d)(?=(?:\d\d\d)+$)", ",", subject)
>>> result
'1,234,567'
法3:
>>> import re
>>> subject = '1234567'
>>> result = re.sub(r"(\d)(?=(\d\d\d)+(?!\d))", r"\1,", subject)
>>> result
'1,234,567'
上一篇: 如何在Python中使用静态变量在计数
下一篇: python编程(指针)
47864
46428
37315
34762
29333
25991
24946
19968
19566
18052
5807°
6434°
5949°
5976°
7081°
5927°
5965°
6456°
6421°
7801°