您正在尝试写出单词出现在哪行的统计数据。这是我的最后一行
for word in sorted(dict.keys()): print(f'{word}: {dict[word]}')
但是这样打印它的样子
else: 4 c: 2 k: 444
我想要这样:
尝试一下,
for key, value in sorted(dict.keys()): print(f'{key}: {value:>5}')
参考Python: Format output string, right alignment