如何在字典键中捕获整数,其中大多数是字符串,但有些是我需要删除的整数。
我试过这个:
def print_words(filename):
dict = create_dict(filename)
for key, val in sorted(dict.items()):
# Integer filter here!
# if not isinstance(dict.key, int) Something wrong here!
print '{1:^5}\t{0:<}'.format(key.encode('utf-8'), val)
return