ip 队列池,依次取,取了放在最后,可以循环取

2020-10-22  本文已影响0人  程序里的小仙女

实现代码:

from collections import deque
IP_LIST=['113.120.34.27:4542', '183.7.209.49:4530', '114.106.156.27:4542', '180.125.197.220:4536', '59.58.49.27:4563',
         '180.122.104.148:4557', '183.165.195.45:4545', '223.242.222.249:4525', '114.229.3.198:4507',
         '114.99.12.227:4576']

def ip_queue(IP_LIST):

    queue=deque(IP_LIST)
    ip = queue.popleft()
    queue.append(ip)
    print(ip)
    return ip

if __name__ == '__main__':
    ip = ip_queue(IP_LIST)

一些有用的python小例子

# import random

# import re
# str1 = '(1)'
# res = re.findall(r'[(](.*?)[)]', str1)[0] 

# print(str1[1])
# print(res)
    

# str2 = '¥193,840 '
# st = str2.split('¥')[1]
# print(st)

# str3 = "268,000"
# num =''
# strlist  = str3.split(',')
# for i in strlist:
#   num += i
# print(int(num))

# def slot_port_num(line):
#     strlist  = line.split(',')
#     total_port_num = 0
#     for singleline in strlist:
#         if (singleline.isdigit()):
#             slot_port_num = int(singleline)
#             total_port_num = total_port_num + slot_port_num

#     print("total port number:", total_port_num)
#     return total_port_num

# slot_port_num(str3)

# time_str = "10月22日 10:00"
# year = "2020"
# mouth = time_str.split('月')[0]
# day = time_str.split('日')[0].split('月')[1]
# time = time_str.split(" ")[1]
# t = str(year + '-' + mouth + '-' + day + " "  + time)
# print(t)


# import time
# import datetime
# t = time.time()                   #原始时间数据
# print (int(t)) 

# list1 = [‘a’,’b’,’c’]
# for i,j in enumerate(list1):
#   return list1[i]
# u = list1[0]

from collections import deque
queue = deque(["Eric", "John", "Michael"])
print(queue)
queue.append("Graham")  
print(queue)       
url = queue.popleft() 
queue.append(url)
print(url)
print(queue)

上一篇下一篇

猜你喜欢

热点阅读