小编alk*_*lik的帖子

TypeError:“bool”类型的对象没有 len()

我有以下代码:

store_id = 1
acc_id = str(store_id)
print("type of acc_id is ", type(acc_id))

x = len(acc_id)
print(x)

if len(acc_id == 1):
    acc_id += '000' + acc_id
Run Code Online (Sandbox Code Playgroud)

输出:

 type of acc_id is  <class 'str'>
 1
 TypeError: object of type 'bool' has no len()
Run Code Online (Sandbox Code Playgroud)

acc_id当显然是一个字符串时,为什么我会收到此错误?

python python-3.x

-1
推荐指数
1
解决办法
9476
查看次数

标签 统计

python ×1

python-3.x ×1