Python で 10_000 は一万
2024-05-10


Python で数字には下線やカンマで区切ることが出来る。
>>> assert 10_000 == 10000
>>> assert 10,000 == 10000
>>> assert 10.000 == 10000
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AssertionError
>>> assert 1,0000 == 10000
欧米だと三桁区切りだが、日本風に四桁区切りでも問題なようだ。
[Programming]
[python]

コメント(全0件)
コメントをする


記事を書く
powered by ASAHIネット