文章詳情頁
python - 多線程小白求問這樣的IP要怎么實(shí)現(xiàn)多線程print?
瀏覽:101日期:2022-06-30 08:16:42
問題描述
def hanshu(b): print(b)a='192.168.1.1-3'for ip in a.split(’,’): if ’-’ in ip:s1, s2 = ip.rsplit(’.’, 1)start, end = map(int, s2.split(’-’))for num in range(start, end+1): b=s1+’.’+str(num) hanshu(b) else:hanshu(ip)
問題解答
回答1:https://pypi.python.org/pypi/IPy/
使用這個(gè)模塊,你的代碼不會(huì)這么難看,而且split(',') 寫錯(cuò)了
回答2:多線程要用的threading模塊吧,不是很明白你要什么
相關(guān)文章:
1. php - 微信開發(fā)驗(yàn)證服務(wù)器有效性2. 求救一下,用新版的phpstudy,數(shù)據(jù)庫過段時(shí)間會(huì)消失是什么情況?3. html - 移動(dòng)端radio無法選中4. mysql - 請問數(shù)據(jù)庫字段為年月日,傳進(jìn)的參數(shù)為月,怎么查詢那個(gè)月所對應(yīng)的數(shù)據(jù)5. Python2中code.co_kwonlyargcount的等效寫法6. python - 如何判斷字符串為企業(yè)注冊名稱7. [python2]local variable referenced before assignment問題8. javascript - vue+iview upload傳參失敗 跨域問題后臺(tái)已經(jīng)解決 仍然報(bào)403,這是怎么回事啊?9. javascript - 我的站點(diǎn)貌似被別人克隆了, google 搜索特定文章,除了域名不一樣,其他的都一樣,如何解決?10. python中怎么對列表以區(qū)間進(jìn)行統(tǒng)計(jì)?
排行榜

熱門標(biāo)簽