python 2.5中的type()在传入字符串时返回错误

python 2.5中的type()在传入字符串时返回错误,python,Python,使用Python 2.5.2(r252:60911,2008年9月30日,15:42:03) 我试着用 type(x) 并在传入此字符串“2014-02-06 00:00:00”时收到以下错误 TypeError:“str”对象不可调用 为什么它不返回str?您可能通过执行以下操作,用字符串隐藏python函数type: >>> type = 'some string' >>> # Lots of code >>> x = 'other

使用Python 2.5.2(r252:60911,2008年9月30日,15:42:03) 我试着用

type(x) 
并在传入此字符串“2014-02-06 00:00:00”时收到以下错误

TypeError:“str”对象不可调用


为什么它不返回str?

您可能通过执行以下操作,用字符串隐藏python函数
type

>>> type = 'some string'
>>> # Lots of code
>>> x = 'other string'
>>> type(x)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'str' object is not callable

但是,任何阅读您的代码的人都会讨厌您。

您可能通过执行以下操作,用字符串隐藏了python函数
type

>>> type = 'some string'
>>> # Lots of code
>>> x = 'other string'
>>> type(x)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'str' object is not callable

但是,任何阅读你的代码的人都会恨你。

哦,是的,事情就是这样。好电话。谢谢如何调用原始函数。我可以调用类似于module_xyz.type(x)的东西吗?@chrise
\uuuu builtins\uuuu.type()
,但是你真的不应该首先使用
type
作为变量名。谢谢Jesse。我从类中调用了type()。当我按照您的建议执行操作时,我得到了NameError:全局名称“myClass\uuuu builtins”未定义。如何从类中执行此操作?抱歉,错过了。谢谢将根据您的建议更改我的变量名。但是很高兴知道这项工作是的,就是这样。好电话。谢谢如何调用原始函数。我可以调用类似于module_xyz.type(x)的东西吗?@chrise
\uuuu builtins\uuuu.type()
,但是你真的不应该首先使用
type
作为变量名。谢谢Jesse。我从类中调用了type()。当我按照您的建议执行操作时,我得到了NameError:全局名称“myClass\uuuu builtins”未定义。如何从类中执行此操作?抱歉,错过了。谢谢将根据您的建议更改我的变量名。但知道周围的工作肯定很好