Heim > Artikel > Backend-Entwicklung > Empfohlene Sammlung |. 1 Python-Bibliothek, 4 tolle Funktionen!
Heute stelle ich eine Python-Bibliothek [filestools] vor, die von einem großen Kerl entwickelt wurde, mit dem jeder vertraut ist.
pip install filestools -i https://pypi.org/simple/ -U1. Baumverzeichnisanzeige
# 这样即可将C盘,切换到D盘 C:\Users\Administrator>D: # 使用cd命令,可以切换到指定盘的指定目录 C:\Users\Administrator>cd C:\Users\Administrator\Desktop\python三剑客\加盟店爬虫
from treedir.tree import tree_dir tree_dir(r"C:\Users\Administrator\Desktop\python三剑客\加盟店爬虫", m_level=7, no_calc=False)
<span style="font-size: 15px;">a.txt</span>
文件,经过一段时间后,我对其中的内容做了修改,得到了最后的<span style="font-size: 15px;">b.txt</span>
。from filediff.diff import file_diff_compare file_diff_compare("a.txt", "b.txt")
<span style="font-size: 15px;">html</span>
网页文件。<span style="font-size: 15px;">黄色</span>
表示改动过的内容,<span style="font-size: 15px;">绿色</span>
表示新添加过的内容,<span style="font-size: 15px;">红色</span>
表示已经删除过的内容。from filediff.diff import file_diff_compare file_diff_compare(file1, file2, diff_out='diff_result.html', max_width=70, numlines=0, show_all=False, no_browser=False)
from watermarker.marker import add_mark # 注意:有些参数是默认参数,你可以随意修改的; add_mark(file, mark, out='output', color='#8B8B1B', size=30, opacity=0.15, space=75, angle=30)
from watermarker.marker import add_mark add_mark(file=r"C:\Users\Administrator\Desktop\大学.jpg", out=r"C:\Users\Administrator\Desktop\python三剑客\加盟店爬虫", mark="黄同学", opacity=0.2, angle=30, space=30)
<span style="font-size: 15px;">大学.jpg</span>
添加一个<span style="font-size: 15px;">黄同学</span>
水印,保存的位置在<span style="font-size: 15px;">加盟店爬虫</span>
文件夹下,透明度是<span style="font-size: 15px;">0.2</span>
,旋转角度是<span style="font-size: 15px;">30°</span>
,字体之间的间隔是<span style="font-size: 15px;">30</span>
。 dient zur Veranschaulichung als Beispiel.
http://www.shixi.com/search/index?key=python
可以看到: 这里有各种不同的请求url,然后 <span style="font-size: 12px;">-H</span>
后面是该请求对应的各种参数。我们需要请求哪个链接,就复制对应的curl。
curl 'http://www.shixi.com/search/index?key=python' \ -H 'Connection: keep-alive' \ -H 'Cache-Control: max-age=0' \ -H 'Upgrade-Insecure-Requests: 1' \ -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36' \ -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9' \ -H 'Referer: http://www.shixi.com/' \ -H 'Accept-Language: zh-CN,zh;q=0.9' \ -H 'Cookie: UM_distinctid=17a50a2c8ea537-046c01e944e72f-6373267-100200-17a50a2c8eb4ff; PHPSESSID=rpprvtdrcrvt54fkr7msgcde17; CNZZDATA1261027457=1711789791-1624850487-https%253A%252F%252Fwww.baidu.com%252F%7C1627741311; Hm_lvt_536f42de0bcce9241264ac5d50172db7=1627741268; Hm_lpvt_536f42de0bcce9241264ac5d50172db7=1627741334' \ --compressed \ --insecure
from curl2py.curlParseTool import curlCmdGenPyScript curl_cmd = """curl 'http://www.shixi.com/search/index?key=python' \ -H 'Connection: keep-alive' \ -H 'Cache-Control: max-age=0' \ -H 'Upgrade-Insecure-Requests: 1' \ -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36' \ -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9' \ -H 'Referer: http://www.shixi.com/' \ -H 'Accept-Language: zh-CN,zh;q=0.9' \ -H 'Cookie: UM_distinctid=17a50a2c8ea537-046c01e944e72f-6373267-100200-17a50a2c8eb4ff; PHPSESSID=rpprvtdrcrvt54fkr7msgcde17; CNZZDATA1261027457=1711789791-1624850487-https%253A%252F%252Fwww.baidu.com%252F%7C1627741311; Hm_lvt_536f42de0bcce9241264ac5d50172db7=1627741268; Hm_lpvt_536f42de0bcce9241264ac5d50172db7=1627741334' \ --compressed \ --insecure""" output = curlCmdGenPyScript(curl_cmd) print(output)
Das obige ist der detaillierte Inhalt vonEmpfohlene Sammlung |. 1 Python-Bibliothek, 4 tolle Funktionen!. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!