Quickpost: PEP 515 – Underscores in Numeric Literals
文章介绍了一种在Python中使用下划线提高数字可读性的方法(如0b1000_0001),并指出该功能自2016年(Python 3.6)起通过PEP 515实现,其他编程语言也有类似支持。 2025-10-25 08:7:10 Author: blog.didierstevens.com(查看原文) 阅读量:25 收藏

Quickpost: PEP 515 – Underscores in Numeric Literals

Filed under: Quickpost — Didier Stevens @ 8:07

While attending a great presentation of Kaitai Struct at Hack.lu 2025, I noticed a binary numeric notation during the demo, that I had never seen before. Something like 0b1000_0001.

I’m familiar with notations in Python like 0b10000001, but not with an underscore thrown in to make the number more readable.

Turns out this exists for almost 10 years in Python (since Python 3.6), and that it is known as PEP 515 – Underscores in Numeric Literals.

And it exists in other programming languages too.


Quickpost info


No comments yet.


文章来源: https://blog.didierstevens.com/2025/10/25/quickpost-pep-515-underscores-in-numeric-literals/
如有侵权请联系:admin#unsafe.sh