TypeError: unsupported operand type(s) for +: 'getset_descriptor' and 'int'
程序员文章站
2022-03-05 12:20:35
...
Traceback (most recent call last):
File "C:\Users\Administrator\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3326, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-2-4b80bb28613a>", line 1, in <module>
runfile('D:/Python/Learning/pandasLearn.py', wdir='D:/Python/Learning')
File "C:\Program Files\JetBrains\PyCharm 2019.3.2\plugins\python\helpers\pydev\_pydev_bundle\pydev_umd.py", line 197, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "C:\Program Files\JetBrains\PyCharm 2019.3.2\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "D:/Python/Learning/pandasLearn.py", line 42, in <module>
test['D'].at[i] = add_month(start, i)
File "D:/Python/Learning/pandasLearn.py", line 32, in add_month
return date(date.year + year, month, date.day)
TypeError: unsupported operand type(s) for +: 'getset_descriptor' and 'int'
我这个错误其实错的也很明显了,TypeError
说不支持操作类型'getset_descriptor' and 'int'
相加,
我这个date.year是getset_descriptor类型,第二个year是int类型,所以两个不能相加,我把变量名字看错了,只需改成正确的int类型就可以正常运行了:
推荐阅读
-
TensorFlow2前向传播碰到的unsupported operand type(s) for *: 'float' and 'NoneType'问题
-
小白入门常见报错:TypeError: unsupported operand type(s) for +: ‘int‘ and ‘str‘ 萌新踩雷!!!
-
Error: unsupported operand type(s) for +:´ dict´ and ´ dict´
-
Django项目debug--TypeError: unsupported operand type(s) for /: ‘str‘ and ‘str‘,分析与解决
-
TypeError: unsupported operand type(s) for /: 'NoneType' and 'NoneType'
-
TypeError: unsupported operand type(s) for +: 'getset_descriptor' and 'int'
-
Django 错误 TypeError: unsupported operand type(s) for PosixPath and str
-
[机器学习实战-ch09]TypeError: unsupported operand type(s) for /: 'map' and 'int'