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
3073ec30
Commit
3073ec30
authored
Jan 09, 2019
by
yangpengflag
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update homework
parent
54e6f94d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
22 deletions
+16
-22
2_homework_question_and_answer.py
+16
-22
No files found.
2_homework_question_and_answer.py
View file @
3073ec30
import
re
import
re
def
question_and_answer
():
def
question_and_answer
():
while
True
:
while
True
:
a
=
input
(
"请输入您的问题:"
)
a
=
input
(
"您好,请问有什么可以帮到您?
\n
"
)
if
(((
"贪心"
or
"贪心学院"
)
and
(
"做什么"
))
in
a
):
if
(((
"贪心"
or
"贪心学院"
)
and
(
"做什么"
))
in
a
):
print
(
"贪心学院是一家高端重视售后服务的在线教育培训机构"
)
# 贪心学院是做什么的?
print
(
"贪心学院是一家高端重视售后服务的在线教育培训机构"
)
# 贪心学院是做什么的?
if
"项目式"
in
a
:
# 什么是项目式培训呢?
print
(
"贪心学院的项目式培训结合了西方项目式培训的优点和国内的现状,最终变化成以训练营的方式进行。
\r\n
做项目为主,老师负责解决部分知识的问题,学生负责自学部分知识,和不停的做项目,把知识巩固。
\r\n
在项目练习中,不仅仅学习到了知识,同时也培养起来良好的学习习惯和解决问题的能力。"
)
if
"强"
in
a
:
# 人工智能哪家强?
print
(
"贪心学院"
)
if
"Python"
and
"课程"
and
"学习"
in
a
:
# Python+AI课程适合什么样的同学学习?
print
(
"无编程基础,并且想学习编程的同学。"
)
if
"Python"
and
"人群"
in
a
:
# Python+AI课程具体更适合哪些人群呢?
print
(
"人群包含很广泛。
\r\n
第一:非IT圈内人群,想通过学习转行到编程领域中
\r\n
第二:已经是IT圈内的,其他语言的开发人员,想学习Python编程
\r\n
第三:已经是IT圈内的,但是并不是开发人员,如产品、测试、运维、DBA等岗位
\r\n
第四:学生,未来想从事编程的工作
\r\n
第五:未来想从事AI领域工作的,可先通过这门课程的学习,打下良好的基础"
)
if
"优势"
in
a
:
# 贪心学院的优势是什么?
print
(
"强大的服务体系,我们拥有每天跟学员沟通的良好服务机制。不放弃任何一个学员,只要来了,就一定要让你学会。"
)
if
"数字"
in
a
:
# 42197393里包含几个数字啊?
if
"数字"
in
a
:
# 42197393里包含几个数字啊?
l
=
re
.
findall
(
"
\
d"
,
a
)
l
=
re
.
findall
(
"
\
d"
,
a
)
print
(
"
%
d个"
%
len
(
l
))
print
(
"
%
d个"
%
len
(
l
))
if
"手机号"
in
a
:
# 下边的号码中,哪些是手机号呢:18475309876,18719462345,17665148777,13332839908,12398028761
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}"
# 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}"
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(reg, a))
print
(
re
.
findall
(
reg1
,
a
))
print
(
re
.
findall
(
reg2
,
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呢?
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]+"
# print(re.findall(r"[\d]+\.[\d]+\.[\d]+\.[\d]+", a))
reg_ip1
=
"[0-2]{1,3}
\
.[
\
d]{1,3}
\
.[
\
d]{1,3}
\
.[
\
d]{1,3}"
# print(re.findall(r'(?<![\.\d])(?:25[0-5]\.|2[0-4]\d\.|[01]?\d\d?\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)(?![\.\d])', a))
print
(
re
.
findall
(
r'(?<![\.\d])(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)(?![\.\d])'
,
a
))
print
(
re
.
findall
(
reg_ip
,
a
))
print
(
re
.
findall
(
reg_ip1
,
a
))
else
:
else
:
continue
continue
if
(
"bye"
or
"拜拜"
or
"再见"
)
in
a
:
if
(
"bye"
or
"拜拜"
or
"再见"
)
in
a
:
...
...
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