# Python3 code to demonstrate working of
# Adding comma between numbers
# Using str.format()
# initializing number
test_num = 1234567
# printing original number
print("The original number is : " + str(test_num))
# Using str.format()
# Adding comma between numbers
res = ('{:, }'.format(test_num))
# printing result
print("The number after inserting commas : " + str(res))
输出:
The original number is : 1234567
The number after inserting commas : 1, 234, 567
【转载】给数字加逗号
于 2023-04-15 04:04:49 首次发布