Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
1
1_homework_安晓东
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
安晓东
1_homework_安晓东
Commits
c08071e0
Commit
c08071e0
authored
Jan 11, 2019
by
牛家玺
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
批改
parent
621626e7
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
15 deletions
+48
-15
homewor_2/__pycache__/__init__.cpython-36.pyc
+0
-0
homewor_2/__pycache__/read_fiel.cpython-36.pyc
+0
-0
homewor_2/read_fiel.py
+14
-8
homework_02/homework_02.py
+27
-0
homework_02/run_main_Algorithm_02.py
+7
-7
No files found.
homewor_2/__pycache__/__init__.cpython-36.pyc
0 → 100644
View file @
c08071e0
File added
homewor_2/__pycache__/read_fiel.cpython-36.pyc
0 → 100644
View file @
c08071e0
File added
homewor_2/read_fiel.py
View file @
c08071e0
import
re
class
ReadFile
():
# 获取文件的信息,切分根据开头数字取出后面对应的信息
def
read_file
(
self
,
file_num
):
with
open
(
'../homework_02/answer_info'
,
encoding
=
'utf-8'
)
as
f
:
s
=
f
.
readlines
()
for
i
in
s
:
# 整个地方可以写绝对地址
with
open
(
'answer_info'
,
encoding
=
'utf-8'
)
as
f
:
for
i
in
f
.
readlines
()
:
h
=
i
.
split
(
'.'
)
if
file_num
in
h
[
0
]:
return
'
\033
[33m
%
s
\033
[0m'
%
h
[
1
]
...
...
@@ -23,14 +25,16 @@ class ReadFile():
print
(
'
\t
'
+
fie
)
except
TypeError
:
print
(
"值不存在"
)
# 换行输出
def
for_split
(
self
,
file_num
,
flg
=
None
):
# 换行输出
def
for_split
(
self
,
file_num
,
flg
=
None
):
s
=
self
.
read_file
(
file_num
)
.
split
(
'>'
)
if
flg
is
not
None
:
for
i
in
range
(
1
,
len
(
s
)
-
1
):
print
(
'
\t
'
+
s
[
i
])
print
(
'
\t
'
+
s
[
i
])
else
:
print
(
s
[
0
])
# 判断字符中包含的数字
def
te
(
self
,
f
):
j
=
len
(
re
.
findall
(
'
\
d'
,
f
))
...
...
@@ -45,8 +49,11 @@ class ReadFile():
u
=
re
.
findall
(
reg
,
s
)
if
u
:
print
(
s
)
def
test_ip
(
self
,
ip
):
h
=
'(
\
d{1,3}.){3}
\
d{1,3}'
# = '^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}
# (?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$'
h
=
'(
\
d{1,3}.){3}
\
d{1,3}'
j
=
re
.
search
(
h
,
ip
)[
1
]
print
(
j
)
...
...
@@ -68,4 +75,3 @@ if __name__ == '__main__':
# s.te('42197里包含几个数字啊?')
# print(s.test_ip('下边的号码中,哪些是手机号呢:18475309876,18719462345,17665148777,13332839908,12398028761'))
s
.
test_ip
(
'1324.231.432.1234,192.168.1.6,10.25.11.8这些信息中,哪些是ip呢'
)
homework_02/homework_02.py
View file @
c08071e0
#算法实现有问题效率太低 可能要遍历整个列表
def
peakIndexInMountainArray
(
A
):
"""
:type A: List[int]
...
...
@@ -11,3 +13,28 @@ def peakIndexInMountainArray(A):
print
(
peakIndexInMountainArray
([
9
,
1
,
15
,
3
]))
# 预期输出 1def peakIndexInMountainArray(A):
#二分查找的实现
def
peakIndexInMountainArray
(
mountain
):
height
=
len
(
mountain
)
low
=
0
while
low
<=
height
:
mid
=
(
height
+
low
)
//
2
if
array
[
mid
]
>
array
[
mid
-
1
]
and
array
[
mid
]
>
array
[
mid
+
1
]:
print
(
mid
)
break
elif
array
[
mid
]
>
array
[
mid
+
1
]:
height
=
mid
-
1
else
:
low
=
mid
+
1
array
=
[
0
,
1
,
0
]
peakIndexInMountainArray
(
array
)
array
=
[
0
,
2
,
1
,
0
]
peakIndexInMountainArray
(
array
)
array
=
[
0
,
1
,
2
,
3
,
7
,
6
,
5
,
4
,
2
,
1
,
0
]
peakIndexInMountainArray
(
array
)
array
=
[
0
,
1
,
2
,
7
,
6
,
5
,
4
,
0
]
peakIndexInMountainArray
(
array
)
homework_02/run_main_Algorithm_02.py
View file @
c08071e0
...
...
@@ -3,7 +3,7 @@ import re
from
homewor_2.read_fiel
import
ReadFile
class
questint_answer
()
:
class
questint_answer
:
read
=
ReadFile
()
def
qustion_an
(
self
):
...
...
@@ -17,18 +17,18 @@ class questint_answer():
elif
re
.
findall
(
'^课程|啥课程'
,
info
):
self
.
read
.
get_info
(
'2'
,
'2'
,
'5'
)
elif
re
.
findall
(
'方式|(学院的课程是什么方式进行上课的?)'
,
info
):
self
.
read
.
get_info
(
1
,
'2'
)
self
.
read
.
get_info
(
1
,
'2'
)
elif
re
.
findall
(
'什么是项目式培训呢?|项目式'
,
info
):
self
.
read
.
get_info
(
1
,
'3'
)
self
.
read
.
get_info
(
1
,
'3'
)
elif
re
.
findall
(
'人工智能哪家强?|^强'
,
info
):
self
.
read
.
get_info
(
1
,
'4'
)
self
.
read
.
get_info
(
1
,
'4'
)
elif
re
.
findall
(
'(Python+AI)课程具体更适合哪些人群呢?|更适合哪些人群'
,
info
):
self
.
read
.
for_split
(
'6'
)
self
.
read
.
for_split
(
'6'
,
'1'
)
elif
re
.
findall
(
'(Python+AI)适合什么样的同学学习?|Python'
,
info
):
self
.
read
.
get_info
(
1
,
'5'
)
self
.
read
.
get_info
(
1
,
'5'
)
elif
re
.
findall
(
'优势是什么?|优势'
,
info
):
self
.
read
.
get_info
(
1
,
'7'
)
self
.
read
.
get_info
(
1
,
'7'
)
elif
re
.
findall
(
'42197393里包含几个数字啊?|
\
d'
,
info
):
self
.
read
.
te
(
info
)
elif
info
==
'下边的号码中,哪些是手机号呢:18475309876,18719462345,17665148777,13332839908,12398028761'
:
...
...
@@ -43,7 +43,7 @@ class questint_answer():
#
# print(type(s))
elif
re
.
findall
(
'拜拜|再见|bye'
,
info
):
elif
re
.
findall
(
'拜拜|再见|bye'
,
info
):
print
(
'
\t
''再见'
)
break
else
:
...
...
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