字典更新问题
dict1 = {}for u in tuple(text) :
dict1 = text.count(u)
print(dict1)
这样的代码为什么不能够更新字典,打印出来是空白! 我这里没有问题?
text = "qiuyouzhi"
dict1 = {}
for u in text: # 字符串本来就是可迭代对象,不用tuple(text)
dict1 = text.count(u)
print(dict1) text是空白 可能因为 text 是空字符串
页:
[1]