Unverified Commit 35afeaed authored by Kiryuu's avatar Kiryuu
Browse files

Initial commit

parents
# python正则表达式综合练习
\ No newline at end of file
import numpy as np
with open('./test_one/Test.py',"r",encoding="utf8") as f:
code = f.read()
hash_name = list("1320")
hash_count = [0]*len(hash_name)
for i, name in enumerate(hash_name):
if name in code:
hash_count[i] = 1
if np.array(hash_count).sum() == 4:
print('切勿投机取巧!')
else:
import Test
Test.re_Regex()
\ No newline at end of file
import re
def re_Regex():
#*********** Begin **********#
# 读取数据文件
# 根据日志数据编写正则表达式提取数据内容
# 提取cs_item_sk的数值以1结尾的并且布尔值为true的所需的日志内容
#*********** End **********#
[main] INFO com.jzdata.press.core.PressTest - select cs_bill_customer_sk,count(*) from catalog_sales where cs_item_sk =2 group by cs_bill_customer_sk order by cs_bill_customer_sk limit 100; true 2640
[main] INFO com.jzdata.press.core.PressTest - select cs_bill_customer_sk,count(*) from catalog_sales where cs_item_sk =16 group by cs_bill_customer_sk order by cs_bill_customer_sk limit 100; true 282
[main] INFO com.jzdata.press.core.PressTest - select cs_bill_customer_sk,count(*) from catalog_sales where cs_item_sk =13 group by cs_bill_customer_sk order by cs_bill_customer_sk limit 100; true 291
[main] INFO com.jzdata.press.core.PressTest - select cs_bill_customer_sk,count(*) from catalog_sales where cs_item_sk =111 group by cs_bill_customer_sk order by cs_bill_customer_sk limit 100; true 320
\ No newline at end of file
import Test
html = input()
with open(html,"r",encoding="utf8") as f:
Test.parse_one_page(f.read())
import re
def parse_one_page(html):
#*********** Begin **********#
#*********** End **********#
<dd>
<i class="board-index board-index-3">3</i>
<a href="/films/2641" title="罗马假日" class="image-link" data-act="boarditem-click" data-val="{movieId:2641}">
<img src="//s3plus.meituan.net/v1/mss_e2821d7f0cfe4ac1bf9202ecf9590e67/cdn-prod/file:5788b470/image/loading_2.e3d934bf.png" alt="" class="poster-default" />
<img data-src="https://p0.meituan.net/movie/289f98ceaa8a0ae737d3dc01cd05ab052213631.jpg@160w_220h_1e_1c" alt="罗马假日" class="board-img" />
</a>
<div class="board-item-main">
<div class="board-item-content">
<div class="movie-item-info">
<p class="name"><a href="/films/2641" title="罗马假日" data-act="boarditem-click" data-val="{movieId:2641}">罗马假日</a></p>
<p class="star">
主演:格利高里·派克,奥黛丽·赫本,埃迪·艾伯特
</p>
<p class="releasetime">上映时间:1953-09-02(美国)</p> </div>
<div class="movie-item-number score-num">
<p class="score"><i class="integer">9.</i><i class="fraction">1</i></p>
</div>
</div>
</div>
</dd>
\ No newline at end of file
<dd>
<i class="board-index board-index-2">2</i>
<a href="/films/1297" title="肖申克的救赎" class="image-link" data-act="boarditem-click" data-val="{movieId:1297}">
<img src="//s3plus.meituan.net/v1/mss_e2821d7f0cfe4ac1bf9202ecf9590e67/cdn-prod/file:5788b470/image/loading_2.e3d934bf.png" alt="" class="poster-default" />
<img data-src="https://p0.meituan.net/movie/283292171619cdfd5b240c8fd093f1eb255670.jpg@160w_220h_1e_1c" alt="肖申克的救赎" class="board-img" />
</a>
<div class="board-item-main">
<div class="board-item-content">
<div class="movie-item-info">
<p class="name"><a href="/films/1297" title="肖申克的救赎" data-act="boarditem-click" data-val="{movieId:1297}">肖申克的救赎</a></p>
<p class="star">
主演:蒂姆·罗宾斯,摩根·弗里曼,鲍勃·冈顿
</p>
<p class="releasetime">上映时间:1994-09-10(加拿大)</p> </div>
<div class="movie-item-number score-num">
<p class="score"><i class="integer">9.</i><i class="fraction">5</i></p>
</div>
</div>
</div>
</dd>
\ No newline at end of file
<dd>
<i class="board-index board-index-1">1</i>
<a href="/films/1203" title="霸王别姬" class="image-link" data-act="boarditem-click" data-val="{movieId:1203}">
<img src="//s3plus.meituan.net/v1/mss_e2821d7f0cfe4ac1bf9202ecf9590e67/cdn-prod/file:5788b470/image/loading_2.e3d934bf.png" alt="" class="poster-default" />
<img data-src="https://p1.meituan.net/movie/20803f59291c47e1e116c11963ce019e68711.jpg@160w_220h_1e_1c" alt="霸王别姬" class="board-img" />
</a>
<div class="board-item-main">
<div class="board-item-content">
<div class="movie-item-info">
<p class="name"><a href="/films/1203" title="霸王别姬" data-act="boarditem-click" data-val="{movieId:1203}">霸王别姬</a></p>
<p class="star">
主演:张国荣,张丰毅,巩俐
</p>
<p class="releasetime">上映时间:1993-01-01</p> </div>
<div class="movie-item-number score-num">
<p class="score"><i class="integer">9.</i><i class="fraction">5</i></p>
</div>
</div>
</div>
</dd>
\ No newline at end of file
import re
def re_test2(input_data):
result=[]
#*********** Begin **********#
#*********** End **********#
return result
\ No newline at end of file
import step2
if __name__ == '__main__':
str = ""
a = input()
for i in a.split(","):
str += "\n"
str += i
print(step2.re_test2(str))
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="Unittests" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/3rahy6ck.iml" filepath="$PROJECT_DIR$/.idea/3rahy6ck.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment