clout = requests.get('https://pastebin.com/raw/j4Amhah6')
with open("MODULEADVANCED.txt", "w") as file:
file.write(clout.text.rstrip())
with open('MODULEADVANCED.txt', "r") as file:
for eachLine in file:
try:
proxies = {
'http': eachLine.rstrip(),
'https': eachLine.rstrip()
}
print(proxies['http'].rstrip())
except:
print("an error has occured")此代码将输出以下内容:
127.0.0.1:0000
127.0.0.1:0000
127.0.0.1:0000
127.0.0.1:0000
127.0.0.1:0000
127.0.0.1:0000这些空格只会给系统增加不合理的负载。我试着到处散布.rstrip(),但是没有结果……
发布于 2018-06-09 05:51:09
解决问题的一种方法(尽管不是正确的方法)是:
print(proxies['http'].rstrip(), end='')如果这会将所有内容打印到一行,那么您可能会将不必要的\n保存到文件中,因此您应该检查第一部分
with open("MODULEADVANCED.txt", "w") as file:
file.write(clout.text.strip())也许吧?
https://stackoverflow.com/questions/50768638
复制相似问题