0
点赞
收藏
分享

微信扫一扫

Python TypeError: ‘str‘ object is not callable

pipu 2022-10-24 阅读 134


0x00 错误

Traceback (most recent call last):
File "/Users/apple/Desktop/Me/Python3/MyCode/kc_v2.py", line 513, in <module>
get_data()
File "/Users/apple/Desktop/Me/Python3/MyCode/kc_v2.py", line 34, in get_rich
query_v1()
File "/Users/apple/Desktop/Me/Python3/MyCode/kc_v2.py", line 68, in query_v1
query_v12(sub, arr, '第一组')
File "/Users/apple/Desktop/Me/Python3/MyCode/kc_v2.py", line 418, in query_v12
print('666 =', type(str2))
TypeError: 'str' object is not callable

出现这个情况错误一般是:
a.​​​str变量​​​ 重复定义
b.​​​变量​​​ 重复定义
c.​​​函数​​​或者​​字符串调用​​错误

0x01 原因

for type in list:
# blablabla
# ....
# ....
# 省略大量代码
# 代码某个地方调用了系统的 type() 函数,导致了这个错误
type(str1)

又是 ​​局部变量​​​ 覆盖了 ​​系统函数​​​ 跟之前写的一篇报错文章一样
Python UnboundLocalError: local variable ‘str‘ referenced before assignment

真特么的蛋疼!
定义个变量都能随时踩坑 😂

0x02 我的作品

欢迎体验我的作品之一:​​小五笔 86 版​​​ 五笔学习好帮手
​App Store​​ 搜索即可~


举报

相关推荐

0 条评论