我不明白为什么每两个循环打印一次空行


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((s,但没有骰子......

解决问题的一种方法(尽管不是正确的方法(是:

print(proxies['http'].rstrip(), end='')

如果这会将所有内容打印在一行上,那么您可能会将不必要的n保存到文件中,因此您应该检查第一部分

with open("MODULEADVANCED.txt", "w") as file:
file.write(clout.text.strip())

或?

最新更新