Python 报错:TypeError: 'str' object is not callable

背景

有时候调用方法时会遇到如下这个错误:

>>> os.name()
Traceback (most recent call last):
  File "", line 1, in <module>
TypeError: 'str' object is not callable

解决方法

表示这个是字符串对象,无法像函数那样调用

>>> os.name
'posix'

你可能感兴趣的:(python,python)