当前位置:网站首页>System performance monitoring system

System performance monitoring system

2022-06-13 05:13:00 I love Qianxi

use python To write scripts to simplify the daily operation and maintenance work is python An important use of , stay linux in , It can be used ps,top,free Such a command to view , stay python in , A good way to get system information is psutil This third-party module , It is python System monitoring and process management tools , It is a powerful cross platform system management library , at present psutil The supported systems are linux,window os X etc.

One 、requests Request Library

1、 Introduce

requests Is an elegant and simple python HTTP Request Library ,requests Send request to get response data

2、 install

At terminal ( Command line tools ) Run the following command

pip install requests
pip list Can view installed Libraries 

Be careful :

1、 If you want to install python In a virtual environment , Enter the virtual environment first, and then execute the above command
2、 If both... Are installed in the system python2, Installed again python3, Need to install python3 Environment :pip3 install requests

3、requests Basic use

1、 The import module
2、 send out get request , Get a response
3、 Get data from the response

1、 The import module 
import requests
2、 Send a request , Get a response 
response=requests.get("http://www.baidu.com")
3、 Get data from the response 
print(response.text)

response Common properties :

response.test: Response string data 
response.encoding: The character encoding used for printing 
response.content: Print the binary data of the response 
 Set the code to utf-8:response.encoding="utf-8"
原网站

版权声明
本文为[I love Qianxi]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202280515156809.html