FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
algorithm/most_char_num2.py at master · yang66/algorithm · GitHub
yang66
algorithm
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
algorithm
/
most_char_num2.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
18 lines (14 loc) · 455 Bytes
Breadcrumbs
algorithm
/
most_char_num2.py
Copy path
File metadata and controls
18 lines (14 loc) · 455 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#! /usr/bin/env python
#coding:utf-8
str1
=
"jjjjjjddddddllooppxx"
def
most_character_number
(
one_string
):
"""利用字典key来统计次数"""
str_dict
=
{}
for
item
in
one_string
:
if
item
in
str_dict
:
str_dict
[
item
]
+=
1
else
:
str_dict
[
item
]
=
1
str_dict
=
{
str_dict
[
key
]:
key
for
key
in
str_dict
}
return
(
max
(
str_dict
),
str_dict
[
max
(
str_dict
)])
print
(
most_character_number
(
str1
))
Back
|
FazBrowse Home
|
New Git URL