下面的Python代码用于实现每个字符后紧跟随字符及其出现次数,并对紧跟随字符排序,即出现次数最多排在前,形如:{'中': [('文', 1), ('国', 2), ('华', 2)]},此处S仅是部分字符,可能很多,横线处应填入代码是( )。

ct476017 单选题 共 个子题
S = """中国华夏中华人民共和国中国人中文"""

dictAfter = {}
for i,hz in enumerate(S[1:]):
    tmpDict = dictAfter.get(S[i], {})
    tmpDict[hz] = tmpDict.get(hz, 0) + 1
    dictAfter[S[i]] = tmpDict
dictAfter = { ________________ for x in dictAfter.items()}
print(dictAfter)
A

x[0]:x[1].items().sort(key = lambda x:x[1], reverse = True)

B

x[0]:x[1].items().sort(key = lambda x:x[0], reverse = True)

C

x[0]:sorted(x[1].items(), key = lambda x:-x[0])

D

x[0]:sorted(x[1].items(), key = lambda x:-x[1])

正在加载题目数据…
已答 /
子题
该题型需在试卷/作业中作答,单题练习暂不支持
答案解析
讨论
发布
登录后参与讨论 立即登录
发布讨论需先绑定并验证手机号 去绑定手机号
加载中…
我
我
回复 @
回复 @
发送
还没有人讨论,来发表第一条吧