解包、map

def cont(ip,port,username,password):
    print(ip)
    print(port)
    print(username)
    print(password)
info=('192.168.1.1',8090,'root','123456')
info_l=['192.168.1.1',8090,'root','123456']
info_dic={'ip':'192.168.1.1','port':8090,'username':'root','password':'123456'}
cont(*info)
cont(*info_l)
cont(**info_dic)
#map 循环调用函数,会保存每次调用的返回值,最后返回
import os
stus=['qqq','www','eee','rrr']
def add_prx(name):
    return 'cnz_%s'%name
res=list(map(add_prx,stus))
print(res)#['cnz_qqq', 'cnz_www', 'cnz_eee', 'cnz_rrr']
#filter循环调用函数,过滤传入的参数,返回结果是true保存,false就不要了import os
stus=['qqq','www','eee','rrr']
def add_prx(name):
    return 'cnz_%s'%name
res=list(filter(add_prx,stus))
print(res)#['qqq', 'www', 'eee', 'rrr']

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值