零零散散的python知识点

PythonFlask

一、PythonFlask是Python轻便级的开源WEB框架。

Python requests

https://requests.readthedocs.io/en/master/user/quickstart/

​ Python requests is an elegent and simple HTTP library for Python.

​ Requests allows you to send HTTP/1.1 requests extrmely easily.There’s no need to manually add query strings to your URLs or to form-encode your POST data.Keep-alive and HTTP connection pooling are 100% automatic, thanks to urllib3?

### Passing Parameters In URLS

​ You often want to send some sort of data in the URLS’s query string.Requests allows you to procide these arguments like “www.xxx.org/get?key=val".The arguments after the question mark as a dictionary of strings as the params keyword argument value at the second option.

​ As an example, if you wanted to pass key1=value1 and key2=value2 to www.xxx.org/get, you would use the following code:

1
2
payload = {"key1" : "value1", "key2" : "value2"}
r = requests.get("www.xxx.org/get", params=payload)

POST:

1
2
payload = {"key1" : "value1", "key2" : "value2"}
r = requests.post("www.xxx.org/get", data=payload)

python re模块

1
2
3
4
5
import re
re.match(pattern, str) #从str首开始匹配patern模式
re.search(pattern, str) #全文检索pattern模式
a = re.search('hel(.*)', "hello")
a.group(1) 返回 lo

开发脚本必备——python命令行知识点

https://www.pyimagesearch.com/2018/03/12/python-argparse-command-line-arguments/

hashlib

1
2
3
4
5
6
7
import hashlib

hashlib.md5(b'').hexdigest() #十六进制摘要

hashlib.md5(b'').digest() #字节流摘要

bytes(需要转化字节流的字符串,encode='utf-8') #要转化的字符串是什么编码?

当前网速较慢或者你使用的浏览器不支持博客特定功能,请尝试刷新或换用Chrome、Firefox等现代浏览器