Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
2
2_homework_yangpeng
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨鹏
2_homework_yangpeng
Commits
54e6f94d
Commit
54e6f94d
authored
6 years ago
by
yangpengflag
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update homework
parent
455f18cd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
9 deletions
+43
-9
2_homework_bubbleSort.py
+2
-2
2_homework_question_and_answer.py
+41
-7
No files found.
2_homework_bubbleSort.py
View file @
54e6f94d
...
...
@@ -18,10 +18,10 @@ def bubbleSort(nums,isAsc):
A
=
[
3
,
4
,
2
,
22
,
7
,
8
]
bubbleSort
(
A
,
isAsc
=
True
)
bubbleSort
(
nums
=
A
,
isAsc
=
True
)
print
(
A
)
bubbleSort
(
A
,
isAsc
=
False
)
bubbleSort
(
nums
=
A
,
isAsc
=
False
)
print
(
A
)
This diff is collapsed.
Click to expand it.
2_homework_question_and_answer.py
View file @
54e6f94d
import
re
def
question_and_answer
():
while
True
:
a
=
input
(
""
)
if
((
"贪心"
or
"贪心学院"
)
and
"做什么"
in
a
):
print
(
"贪心学院是一家高端重视售后服务的在线教育培训机构"
)
if
"bye"
in
a
:
print
(
"拜拜,回聊!"
)
a
=
input
(
"请输入您的问题:"
)
if
(((
"贪心"
or
"贪心学院"
)
and
(
"做什么"
))
in
a
):
print
(
"贪心学院是一家高端重视售后服务的在线教育培训机构"
)
# 贪心学院是做什么的?
if
"数字"
in
a
:
# 42197393里包含几个数字啊?
l
=
re
.
findall
(
"
\
d"
,
a
)
print
(
"
%
d个"
%
len
(
l
))
if
"手机号"
in
a
:
# 下边的号码中,哪些是手机号呢:18475309876,18719462345,17665148777,13332839908,12398028761
reg
=
"13
\
d{9}|14[579]
\
d{8}|15[^4
\
D]
\
d{8}|17[^49
\
D]
\
d{8}|18
\
d{9}"
reg1
=
"1[3,4,5,7,8]
\
d{9}"
reg2
=
"13[0-9]
\
d{8}|14[5,7]
\
d{8}|15[0-3,5-9]
\
d{8}|17[0-3,5-8]
\
d{8}|18[0-9]
\
d{8}|166
\
d{8}|19[8-9]
\
d{8}"
print
(
re
.
findall
(
reg
,
a
))
print
(
re
.
findall
(
reg1
,
a
))
print
(
re
.
findall
(
reg2
,
a
))
if
"ip"
or
"IP"
in
a
:
# 1324.231.432.1234,192.168.1.6,10.25.11.8这些信息中,哪些是ip呢?
reg_ip
=
"[
\
d]+
\
.[
\
d]+
\
.[
\
d]+
\
.[
\
d]+"
reg_ip1
=
"[0-2]{1,3}
\
.[
\
d]{1,3}
\
.[
\
d]{1,3}
\
.[
\
d]{1,3}"
print
(
re
.
findall
(
reg_ip
,
a
))
print
(
re
.
findall
(
reg_ip1
,
a
))
else
:
continue
if
(
"bye"
or
"拜拜"
or
"再见"
)
in
a
:
print
(
"再见!"
)
break
question_and_answer
()
\ No newline at end of file
question_and_answer
()
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment