Python實(shí)現(xiàn)手機(jī)號(hào)自動(dòng)判斷男女性別(實(shí)例解析)
本文性別判斷主要依靠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
以上是用的是airtest實(shí)現(xiàn)的,效率不是很高,同樣進(jìn)行簡(jiǎn)單改動(dòng)可以實(shí)現(xiàn)支付寶真實(shí)號(hào)碼篩選,效率很高,偶爾使用一下還是可以的,切不可用于非法用途,大家有什么好的方式歡迎留言!
總結(jié)
以上所述是小編給大家介紹的Python實(shí)現(xiàn)手機(jī)號(hào)自動(dòng)判斷男女性別,希望對(duì)大家有所幫助!
相關(guān)文章
Python 程序報(bào)錯(cuò)崩潰后如何倒回到崩潰的位置(推薦)
這篇文章主要介紹了Python 程序報(bào)錯(cuò)崩潰后如何倒回到崩潰的位置,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-06-06
Python實(shí)現(xiàn)周日歷與時(shí)間相互轉(zhuǎn)換
周日歷是日常生活中不常用到的歷法系統(tǒng),一般用于政府、商務(wù)的會(huì)計(jì)年度或者學(xué)校教學(xué)日歷中。本文為大家介紹了如何利用Python語(yǔ)言實(shí)現(xiàn)周日歷與時(shí)間相互轉(zhuǎn)換,感興趣的可以學(xué)習(xí)一下2022-07-07
Python進(jìn)程池Pool應(yīng)用實(shí)例分析
這篇文章主要介紹了Python進(jìn)程池Pool應(yīng)用,結(jié)合實(shí)例形式分析了Python進(jìn)程池Pool功能、使用方法及相關(guān)操作注意事項(xiàng),需要的朋友可以參考下2019-11-11
python 對(duì)類的成員函數(shù)開(kāi)啟線程的方法
今天小編就為大家分享一篇python 對(duì)類的成員函數(shù)開(kāi)啟線程的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-01-01
Anaconda中更新當(dāng)前環(huán)境的Python版本詳細(xì)步驟
Anaconda是一個(gè)開(kāi)源的Python發(fā)行版本,其包含了conda、Python等180多個(gè)科學(xué)包及其依賴項(xiàng),下面這篇文章主要給大家介紹了關(guān)于Anaconda中更新當(dāng)前環(huán)境的Python版本的詳細(xì)步驟,需要的朋友可以參考下2024-08-08
Python button選取本地圖片并顯示的實(shí)例
今天小編就為大家分享一篇Python button選取本地圖片并顯示的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-06-06

