python 两个列元素拼接

2020-07-06  本文已影响0人  随便写点什么就好

有两个列表,我需要把对应的元素拼接起来.
['192.168.111.116', '192.168.110.285', '192.168.110.184']
['3306', '3307', '3307']

要拼接成 192.168.111.116:3306

def getMasterHost(buff,informationId):
    masterHostTmp = re.findall(r"Master_Host:\s*(.*?)\s*Master_User",buff)
    masterPortTmp = re.findall(r"Master_Port:\s*(\d*?)\s*Connect_Retry",buff)
    print("输出该从库的主库源信息:")
    print(masterHostTmp)
    print("输出该从库的主库端口信息:")
    print(masterPortTmp)
    listTmp = []
    for i in range(0,len(masterHostTmp)):
        listTmp.append(masterHostTmp[i]+":"+masterPortTmp[i])
    print(listTmp)

从mysql的show slave status\G;截取出多源从库的新主库信息.

上一篇 下一篇

猜你喜欢

热点阅读