1. 程式人生 > >python學習筆記01-特殊參數的使用

python學習筆記01-特殊參數的使用

ngs lec file header toc mps aps ray name

1、請求攜帶參數的方式
1、帶數據的post data=字典對象
2、帶header的post headers=字典對象
3、帶json的post json=json對象
4、帶參數的post params=字典對象
5、普通文件上傳 files= files = {‘file‘:open(‘filaname.txt‘,‘rb‘)}
6、定制化文件上傳 files= files = {‘file‘:(‘filaname.png‘,open(‘filaname.png‘,‘rb‘),‘image/png‘)}
7、多文件上傳 files= files={‘file‘:(‘filaname.png‘,open(‘filaname.png‘,‘rb‘),‘image/png‘)}


2、json與python轉換
json.dumps demjson.encode() 將Python對象編碼成JSON字符串
json.loads demjson.decode() 將已編碼的JSON字符串解碼為Python對象


3、json與python對應關系
objcet dict
array list
string unicode
number(int) int,long
number(real) float
true True
false False
null None


4、請求中的特殊參數
#禁止自動重定向
allow_redirects=False

#超時時間
timeout=None

#去掉ssl驗證
verify=False

#去掉警告提示
urllib3.disable_warnings()

#響應時間
res.elapsed.total_seconds()

5、元素定位
find_by_css_xpath("//*[@autocomplete="off"]")
find_by_css_selector("[autocomplete=‘off‘]")
find_by_css_selector("//input[@autocomplete="off"]")
find_by_css_selector("input#kw")
driver.find_element_by_xpath(‘/html/body/input‘).send_keys();

python學習筆記01-特殊參數的使用