小编ksl*_*te1的帖子

为什么python在"."之后允许对象和方法名之间的空格.

有谁知道为什么python允许你在一个对象和被称为"."的方法的名称之间放置无限量的空格.?

这里有些例子:

 >>> x = []
 >>> x.            insert(0, 'hi')
 >>> print x
 ['hi']
Run Code Online (Sandbox Code Playgroud)

另一个例子:

>>> d = {}
>>> d            ['hi'] = 'there'
>>> print d
{'hi': 'there'}
Run Code Online (Sandbox Code Playgroud)

课程也是如此.

>>> myClass = type('hi', (), {'there': 'hello'})
>>> myClass.            there
'hello'
Run Code Online (Sandbox Code Playgroud)

我正在使用python 2.7我尝试做一些谷歌搜索并查看python源代码,但我找不到任何理由为什么这是允许的.

python python-2.7

6
推荐指数
1
解决办法
912
查看次数

标签 统计

python ×1

python-2.7 ×1