我不明白如何通过'任意'顺序完成字典或python中的循环.
我的意思是,它是一种编程语言,所以语言中的所有内容都必须100%确定,对吗?Python必须有某种算法来决定选择字典或集合的哪一部分,第一,第二等等.
我错过了什么?
输出为:是否
Counter({'l': 2, 'h': 1, 'e': 1, 'o': 1})
可以删除“ Counter”字样?
from collections import Counter
word = "hello"
print(Counter(word))
Run Code Online (Sandbox Code Playgroud)