我有以下代码:
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当显然是一个字符串时,为什么我会收到此错误?