您好,登錄后才能下訂單哦!
小編給大家分享一下Python怎么實(shí)現(xiàn)手機(jī)號(hào)自動(dòng)判斷男女性別,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!
本文性別判斷主要依靠airtest中的自動(dòng)化測(cè)試實(shí)現(xiàn)
通過(guò)自動(dòng)對(duì)比支付寶頁(yè)面男女圖像,從而實(shí)現(xiàn)男女判斷
代碼如下:
男女判斷函數(shù):
// An highlighted block def numbe(): if exists(Template(r"tpl1574867500094.png", threshold=0.85, rgb=True, target_pos=0, record_pos=(0.779, 0.382), resolution=(960, 540))): sex = "女" if exists(Template(r"tpl1574924960910.png", threshold=0.89, rgb=True, target_pos=5, record_pos=(0.779, 0.382), resolution=(960, 540))): sex = "男" else: sex = "不存在" namesex = sex keyevent("4") return namesex 手機(jī)滑動(dòng)(根據(jù)手機(jī)分辨率自行調(diào)整): // An highlighted block def scoll(): try: swipe(v1=(629, 1750),v2=(629, 310)) # 滑動(dòng)距離需要根據(jù)手機(jī)分辨率自行調(diào)整 except: print("can't go back to the main page")
刷選函數(shù):
// An highlighted block def number(): data_list =[] for i in range(9): # 根據(jù)手機(jī)分辨率自行調(diào)整 try: title =poco(name="com.alipay.mobile.contactsapp:id/contact_item_name")[i].get_text() name = poco(name="com.alipay.mobile.contactsapp:id/concast_from")[i].get_text() print(title) name_a =name[5:6] if title not in data_list and name_a is not "1": poco("com.alipay.mobile.contactsapp:id/contact_item_name")[i].click() sexname=numbe() if sexname =="男": print(str(sexname)) else: print(str(sexname)) else: print(name_a) print("不存在") except: print("出錯(cuò),跳過(guò)!")
綜合:
// An highlighted block # -*- encoding=utf8 -*- __author__ = "liuqingsong" def numbe(): if exists(Template(r"tpl1574867500094.png", threshold=0.85, rgb=True, target_pos=0, record_pos=(0.779, 0.382), resolution=(960, 540))): sex = "女" if exists(Template(r"tpl1574924960910.png", threshold=0.89, rgb=True, target_pos=5, record_pos=(0.779, 0.382), resolution=(960, 540))): sex = "男" else: sex = "不存在" namesex = sex keyevent("4") return namesex def scoll(): try: swipe(v1=(629, 1750),v2=(629, 310)) # 滑動(dòng)距離需要根據(jù)手機(jī)分辨率自行調(diào)整 except: print("can't go back to the main page") def number(): data_list =[] for i in range(9): # 根據(jù)手機(jī)分辨率自行調(diào)整 try: title =poco(name="com.alipay.mobile.contactsapp:id/contact_item_name")[i].get_text() name = poco(name="com.alipay.mobile.contactsapp:id/concast_from")[i].get_text() print(title) name_a =name[5:6] if title not in data_list and name_a is not "1": poco("com.alipay.mobile.contactsapp:id/contact_item_name")[i].click() sexname=numbe() if sexname =="男": print(str(sexname)) with open(r'./new/男.csv','a',encoding='utf-8') as f: f.write("{},{}\n".format(title,sexname)) else: print(str(sexname)) with open(r'./new/女.csv','a',encoding='utf-8') as f: f.write("{},{}\n".format(title,sexname)) else: print(name_a) print("不存在") except: print("出錯(cuò),跳過(guò)!") a=0 while a<5:#根據(jù)手機(jī)上號(hào)碼量的多少自行選擇 number() scoll() sleep(1) a=a+1
看完了這篇文章,相信你對(duì)“Python怎么實(shí)現(xiàn)手機(jī)號(hào)自動(dòng)判斷男女性別”有了一定的了解,如果想了解更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道,感謝各位的閱讀!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。