python3 AttributeError: 'function' object has no attribute 'func_name'

AttributeError: 'function' object has no attribute 'func_name'

python2升级到python3报的错,

python3.0的函数没有func_name属性了,改成了__name__.

详见 官方文档:https://docs.python.org/3/whatsnew/3.0.html#miscellaneous-other-changes

  • The function attributes named func_X have been renamed to use the __X__ form, freeing up these names in the function attribute namespace for user-defined attributes. To wit, func_closurefunc_codefunc_defaultsfunc_dictfunc_docfunc_globalsfunc_name were renamed to __closure____code____defaults____dict____doc____globals____name__, respectively.

  • __nonzero__() is now __bool__().

你可能感兴趣的:(python)