简体   繁体   English

为什么有两个内置的int()函数?

[英]Why are there two built-in int() functions?

Looking at the python documentation here , there is both an int(x=0) and an int(x, base = 10). 这里查看 python文档,有一个int(x = 0)和一个int(x,base = 10)。 Why can't there just be a single function, something like int(x=0, base = 10)? 为什么不能只有一个函数,例如int(x = 0,base = 10)?

It is just a single function (or rather, a single type, which is a callable object). 它只是一个函数(或更确切地说,是一个单一类型,它是一个可调用对象)。 The documentation is just written that way to show that there are two ways to use it. 该文档只是以这种方式编写,以表明有两种使用方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM