Python编号中的下划线 [英] Underscores in Python numbers

查看:97
本文介绍了Python编号中的下划线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到一个关于添加在Python中数字内部可选下划线的可能性的讨论。这是一个受欢迎的选项

可在几个竞争中获得。脚本langauges,我很想用Python看看



例子:

1_234_567

0xdead_beef

3.141_592


如果有人能找到关于此主题的先前

讨论的指针,或者添加,我将不胜感激它是一个Python功能愿望清单。


- Gustav

I tried finding a discussion around adding the possibility to have
optional underscores inside numbers in Python. This is a popular option
available in several "competing" scripting langauges, that I would love
to see in Python.

Examples:
1_234_567
0xdead_beef
3.141_592

Would appreciate if someone could find a pointer to a previous
discussion on this topic, or add it to a Python-feature-wishlist.

- Gustav

推荐答案

Gustav H ?llberg写道:
Gustav H?llberg wrote:
我试图找到一个关于添加在Python中的数字内部可选下划线的可能性的讨论。这是一个受欢迎的选项,可用于几个竞争的选项。脚本langauges,我希望用Python看看。

例子:
1_234_567
0xdead_beef
3.141_592

如果有人能够找到关于此主题的先前讨论的指针,或者将其添加到Python功能愿望清单,我将不胜感激。

- Gustav
I tried finding a discussion around adding the possibility to have
optional underscores inside numbers in Python. This is a popular option
available in several "competing" scripting langauges, that I would love
to see in Python.

Examples:
1_234_567
0xdead_beef
3.141_592

Would appreciate if someone could find a pointer to a previous
discussion on this topic, or add it to a Python-feature-wishlist.

- Gustav




我不知道_s的用途是什么,但我猜他们用作

分隔符(。或,,依赖于你来自哪里)。我觉得_s

对我来说看起来很难看,而且,下划线看起来更像是空格而不是

分隔符。



I''m not sure what the _s are for, but I''m guessing they serve as
separators ("." or "," depending on where you''re from). I think the _s
look ugly to me, besides, underscores look more like spaces than
separators.

Gustav H?llberg写道:
Gustav H?llberg wrote:
我试图找到一个关于在Python中添加数字内部可选下划线的可能性的讨论。这是一个受欢迎的选项,可用于几个竞争的选项。脚本langauges,我希望用Python看看。

例子:
1_234_567
0xdead_beef
3.141_592

如果有人能够找到关于此主题的先前讨论的指针,或者将其添加到Python功能愿望清单中,我将不胜感激。
I tried finding a discussion around adding the possibility to have
optional underscores inside numbers in Python. This is a popular option
available in several "competing" scripting langauges, that I would love
to see in Python.

Examples:
1_234_567
0xdead_beef
3.141_592

Would appreciate if someone could find a pointer to a previous
discussion on this topic, or add it to a Python-feature-wishlist.




也许这些主题,通过谷歌?

http://groups.google.com/group/comp....ls+underscores

-Peter



Perhaps these threads, via Google?

http://groups.google.com/group/comp....ls+underscores
-Peter


2005年11月7日18:02:09 -0800 comp.lang.python,Gustav H?llberg

< gu * ***@gmail.com>写道:
On 7 Nov 2005 18:02:09 -0800 in comp.lang.python, "Gustav H?llberg"
<gu****@gmail.com> wrote:
我试图找到一个关于添加在Python中的数字内部可选下划线的可能性的讨论。这是一个受欢迎的选项,可用于几个竞争的选项。脚本langauges,我希望用Python看看。

例子:
1_234_567
0xdead_beef
3.141_592

如果有人能够找到关于此主题的先前讨论的指针,或者将其添加到Python功能愿望清单中,我将不胜感激。
I tried finding a discussion around adding the possibility to have
optional underscores inside numbers in Python. This is a popular option
available in several "competing" scripting langauges, that I would love
to see in Python.

Examples:
1_234_567
0xdead_beef
3.141_592

Would appreciate if someone could find a pointer to a previous
discussion on this topic, or add it to a Python-feature-wishlist.




我''我从来没有在Python中需要它们,但是我经常希望它们在C中使用
。对于二进制数字,它们是0b(0 | 1)*,它们甚至会是

更有用。


当然,我在C中编写了比Python多_far_的代码。但是我已经看到了足够的错误,有人写了1200000,当他们意味着
12000000时,我认为能够指定12_000_000很有价值。 />

问候,

- =戴夫


-

变化是不可避免的,进步不是。



I''ve never needed them in Python, but I''ve very often wished for them
in C. Along with 0b(0|1)* for binary numbers, where they''d be even
more useful.

Of course, I write _far_ more code in C than Python. But I''ve seen
enough bugs of the sort where someone wrote 1200000 when they meant
12000000, that I see great value in being able to specify 12_000_000.

Regards,
-=Dave

--
Change is inevitable, progress is not.


这篇关于Python编号中的下划线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆