dic1 = {
'a':1, 'b':2, 'c':3}
# keys = list(dic1)
keys = dic1.keys()
keys.remove('b')
print(keys)
报错
AttributeError: 'dict_keys' object has no attribute 'remove'
改为如下即可:
dic1 = {
'a':1, 'b':2, 'c':3}
keys = list(dic1)
# keys = dic1.keys()
keys.remove('b')
print(keys)
输出:
['a', 'c']