【发布时间】:2022-01-17 19:46:56
【问题描述】:
所以我有一个字符串列表,我想将每个字符串都放在我的代码中。我该怎么做?
import requests
import json
import threading
import random
import socket
import struct
i = 0
def fg():
Api = "https://api.mcsrvstat.us/2/"
f = (List)
a = (Api + f)
r = requests.get(a)
h = r.json()
print (json.dumps(h, indent = 2))
while i <= 10:
t1 = threading.Thread(target=fg)
t1.start()
t2 = threading.Thread(target=fg)
t2.start()
t3 = threading.Thread(target=fg)
t3.start()
t4 = threading.Thread(target=fg)
t4.start()
这将是字符串列表,我希望每个字符串都通过 fg 部分
127.0.1.1
127.0.2.1
127.0.3.1
127.0.4.1
我希望它输出
https://api.mcsrvstat.us/2/127.0.1.1
https://api.mcsrvstat.us/2/127.0.2.1
https://api.mcsrvstat.us/2/127.0.3.1
https://api.mcsrvstat.us/2/127.0.4.1
【问题讨论】:
-
我假设 List 是您问题中提到的 IP 地址的 Python 列表。但是你为什么要运行 44 个线程呢?此外, a = (Api + f) 不会帮助您。考虑一下并进行一些调试。你会发现它很有启发性