登录
记住
注册
在线问答系统
问题
未回答
标签
分类
用户
提问
提问
20240313第二次测试-词频统计
+15
投票
最新提问
3月 14, 2024
分类:
编码思路
|
用户:
Daniel
9
4
3
(
2.5k
分)
可行方案之一
#词频统计
freq = {}
line = input()
for word in line.split(' '):
freq[word] = freq.get(word,0)+1
words = sorted(freq.keys())
for w in words:
print ("{word}:{frequence}".format(word=w,frequence=freq[w]))
learning
请
登录
或者
注册
后回答这个问题。
2
个回答
0
投票
最新回答
3月 17, 2024
用户:
长十郎
9
5
5
(
1.4k
分)
str1=input('')
strs=sorted(str1.split(' '))
dic={}
strs1=strs
for str in strs:
if str not in dic.keys():
dic[str]=1
else:
dic[str]+=1
for key,value in dic.items():
print('{}:{}'.format(key,value))
发表于
3月 17, 2024
用户:
长十郎
9
5
5
(
1.4k
分)
第四行删掉
请
登录
或者
注册
后再添加评论。
0
投票
最新回答
4月 24, 2024
用户:
hhhccc
5
1
(
530
分)
message
=
input
()
list
=
message
.
split
(
' '
)
list
.
sort
()
dictionary
=
{}
for
l
in
list
:
if
l
not
in
dictionary
:
dictionary
[
l
]
=
1
else
:
dictionary
[
l
]
=
dictionary
[
l
]
+
1
for
k
,
y
in
dictionary
.
items
():
print
(
k
,
end
=
':'
)
print
(
y
)
请
登录
或者
注册
后再添加评论。
欢迎来到 在线问答系统 ,有什么不懂的可以尽管在这里提问,你将会收到社区其他成员的回答。
...