[英]append quotation marks to links in a file in python
10.10.10.10:8000
10.10.10.10:8001
file_lines = ['"http":','"http://"'+,.join([' '])for x in f.readlines(),+',"']
“http”: “http://10.10.10.10:8000”,
“https”: “http://10.10.10.10:8001”,
:) :)
I don't know if this is what you need, but I coded something real quick.我不知道这是否是您需要的,但我很快就编写了一些代码。
But keep in mind:但请记住:
So I hope this helps:所以我希望这会有所帮助:
lineList = [line.rstrip('\n') for line in open("path_to_data.txt")]
outArr = []
for line in lineList:
outArr.append('"http": ' + '"http://'+ line + '",')
for item in outArr:
print(item)
I tested it with this data:我用以下数据对其进行了测试:
10.10.10.10:8000
10.10.10.11:8000
10.10.10.12:8000
10.10.10.13:8000
10.10.10.14:8000
10.10.10.15:8000
10.10.10.16:8000
10.10.10.17:8000
And this is my output:这是我的输出:
"http": "http://10.10.10.10:8000",
"http": "http://10.10.10.11:8000",
"http": "http://10.10.10.12:8000",
"http": "http://10.10.10.13:8000",
"http": "http://10.10.10.14:8000",
"http": "http://10.10.10.15:8000",
"http": "http://10.10.10.16:8000",
"http": "http://10.10.10.17:8000",
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.