FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
algorithm/delete_space.py at master · guyuyun/algorithm · GitHub
guyuyun
algorithm
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
algorithm
/
delete_space.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
15 lines (13 loc) · 508 Bytes
Breadcrumbs
algorithm
/
delete_space.py
Copy path
File metadata and controls
15 lines (13 loc) · 508 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
#! /usr/bin/env python
#coding:utf-8
#删除一个字符串中连续超过一次的空格。
def
del_space
(
string
):
split_string
=
string
.
split
(
" "
)
#以空格为分割,生成list,list中如果含有空格,则该空格是连续空格中的后一个
string_list
=
[
i
for
i
in
string
if
i
!=
""
]
result_string
=
" "
.
join
(
string_list
)
return
result_string
if
__name__
==
"__main__"
:
one_str
=
"Hello, I am Qiwsir."
string
=
del_space
(
one_str
)
print
one_str
print
string
Back
|
FazBrowse Home
|
New Git URL