Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
1
1-homework-yanjun
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
bonnieyan
1-homework-yanjun
Commits
f37222ff
Commit
f37222ff
authored
Jan 08, 2019
by
bonnieyan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
第二次作业
parent
17566740
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
107 additions
and
0 deletions
+107
-0
2-homework-yanjun/botv0.1.py
+48
-0
2-homework-yanjun/bubbleSort.py
+13
-0
2-homework-yanjun/peakIndexInMountainArray.py
+14
-0
2-homework-yanjun/test.py
+32
-0
No files found.
2-homework-yanjun/botv0.1.py
0 → 100644
View file @
f37222ff
import
re
while
True
:
s
=
input
()
if
(
"贪心"
or
"贪心学院"
)
and
(
"做什么"
)
in
s
:
print
(
"贪心学院是一家高端重视售后服务的在线教育培训机构"
)
elif
(
"贪心"
or
"贪心学院"
)
and
(
"课程"
)
and
(
"方式"
)
in
s
:
print
(
"项目式培训"
)
elif
(
"项目式"
)
in
s
:
print
(
"贪心学院的项目式培训结合了西方项目式培训的优点和国内的现状,最终变化成以训练营的方式进行。
\n
做项目为主,老师负责解决部分知识的问题,学生负责自学部分知识,和不停的做项目,把知识巩固。
\n
在项目练习中,不仅仅学习到了知识,同时也培养起来良好的学习习惯和解决问题的能力。"
)
elif
"强"
in
s
:
print
(
"贪心学院"
)
elif
(
"Python"
)
and
(
"课程"
)
and
(
"学习"
)
in
s
:
print
(
"无编程基础,并且想学习编程的同学。"
)
elif
(
"Python"
)
and
(
"人群"
)
in
s
:
print
(
"人群包含很广泛。
\n
第一:非IT圈内人群,想通过学习转行到编程领域中
\n
第二:已经是IT圈内的,其他语言的开发人员,想学习Python编程
\n
第三:已经是IT圈内的,但是并不是开发人员,如产品、测试、运维、DBA等岗位
\n
第四:学生,未来想从事编程的工作
\n
第五:未来想从事AI领域工作的,可先通过这门课程的学习,打下良好的基础"
)
elif
"优势"
in
s
:
print
(
"强大的服务体系,我们拥有每天跟学员沟通的良好服务机制。不放弃任何一个学员,只要来了,就一定要让你学会。"
)
elif
"数字"
in
s
:
r
=
re
.
search
(
"
\
d*"
,
s
)
.
group
(
0
)
print
(
str
(
len
(
r
))
+
"个"
)
elif
"手机号"
in
s
:
rs
=
re
.
findall
(
"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}|198
\
d{8}|199
\
d{8}|147
\
d{8}"
,
s
)
print
(
rs
)
elif
"ip"
in
s
:
text1
=
re
.
findall
((
"
\
d+.
\
d+.
\
d+.
\
d*"
),
s
)
#print(text1)
for
i
in
range
(
len
(
text1
)
-
1
):
result
=
re
.
findall
(
"^(1
\
d{2}|2[0-4]
\
d|25[0-5]|[1-9]
\
d|[1-9])
\
.(1
\
d{2}|2[0-4]
\
d|25[0-5]|[1-9]
\
d|
\
d)
\
.(1
\
d{2}|2[0-4]
\
d|25[0-5]|[1-9]
\
d|
\
d)
\
.(1
\
d{2}|2[0-4]
\
d|25[0-5]|[1-9]
\
d|
\
d)$"
,
text1
[
i
])
if
result
:
continue
else
:
del
text1
[
i
]
print
(
text1
)
elif
re
.
findall
(
"再见|bye|拜拜"
,
s
):
print
(
"再见"
)
break
2-homework-yanjun/bubbleSort.py
0 → 100644
View file @
f37222ff
#冒泡排序
def
bubbleSort
(
A
):
for
i
in
range
(
len
(
A
)
-
1
):
for
j
in
range
(
len
(
A
)
-
i
-
1
):
if
A
[
j
]
>
A
[
j
+
1
]:
A
[
j
],
A
[
j
+
1
]
=
A
[
j
+
1
],
A
[
j
]
print
(
A
)
if
__name__
==
'__main__'
:
bubbleSort
([
1
,
15
,
2
,
5
,
3
,
18
,
6
])
\ No newline at end of file
2-homework-yanjun/peakIndexInMountainArray.py
0 → 100644
View file @
f37222ff
#山脉数组
def
peakIndexInMountainArray
(
A
):
index
=
0
for
i
in
range
(
1
,
len
(
A
)):
if
A
[
i
-
1
]
<
A
[
i
]
>
A
[
i
+
1
]:
index
=
i
print
(
index
)
if
__name__
==
'__main__'
:
peakIndexInMountainArray
([
0
,
1
,
0
])
peakIndexInMountainArray
([
0
,
2
,
1
,
0
])
\ No newline at end of file
2-homework-yanjun/test.py
0 → 100644
View file @
f37222ff
import
re
s
=
"下边的号码中,哪些是手机号呢:18475309876,18719462345,17665148777,13332839908,12398028761"
# s1 = re.findall("\d{11}",s)
# print(s1)
# for i in range(len(s1)):
# result = re.findall("((13[0-9])|(14[5,7])|(15[0-3,5-9])|(17[0,3,5-8])|(18[0-9])|166|198|199|(147))\d{8}$",s1[i])
# if result:
# continue
# else:
# del s1[i]
# print(s1)
r
=
re
.
findall
(
"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}|198
\
d{8}|199
\
d{8}|147
\
d{8}"
,
s
)
print
(
r
)
#
text
=
"1324.231.432.12934,192.168.1.6,10.25.11.8 这些信息中,哪些是ip呢?"
text1
=
re
.
findall
((
"
\
d+.
\
d+.
\
d+.
\
d*"
),
text
)
print
(
text1
)
for
i
in
range
(
len
(
text1
)
-
1
):
result
=
re
.
findall
(
"^(1
\
d{2}|2[0-4]
\
d|25[0-5]|[1-9]
\
d|[1-9])
\
.(1
\
d{2}|2[0-4]
\
d|25[0-5]|[1-9]
\
d|
\
d)
\
.(1
\
d{2}|2[0-4]
\
d|25[0-5]|[1-9]
\
d|
\
d)
\
.(1
\
d{2}|2[0-4]
\
d|25[0-5]|[1-9]
\
d|
\
d)$"
,
text1
[
i
])
if
result
:
continue
else
:
del
text1
[
i
]
print
(
text1
)
sd
=
"525663314里包含几个数字啊?"
r
=
re
.
search
(
"
\
d*"
,
sd
)
.
group
(
0
)
print
(
str
(
len
(
r
))
+
"个"
)
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