热点网站统计 Python (有疑惑!!!)
题目详情:https://www.nowcoder.com/discuss/368536502547042304
input_str = [
"news.qq.com",
"www.cctv.com",
"1",
"www.huawei.com",
"www.huawei.com",
"2",
"3",
]
url_str = []
ans_str = []
for i_str in input_str:
if i_str.find("."):
url_str.append(i_str)
elif all("0" <= s <= "9" for s in i_str):
cnt = Counter(url_str)
for k, _ in cnt.most_common(int(i_str)):
ans_str.append(k)
#
print(",".join(ans_str))
#
ans_str = []
else:
pass
#########################################################################################
#########################################################################################
#########################################################################################
while True:
input_str = input()
#
url_str = []
ans_str = []
if input_str.find("."):
url_str.append(input_str)
elif all("0" <= s <= "9" for s in input_str):
cnt = Counter(url_str)
for k, _ in cnt.most_common(int(input_str)):
ans_str.append(k)
#
print(",".join(ans_str))
#
ans_str = []
else:
pass
#########################################################################################
#########################################################################################
#########################################################################################
疑惑:华为OD机试中这道题是怎么处理输入的?有没有知道的朋友???
#华为OD##HashMap##悬赏#
查看22道真题和解析