(May-04-2019, 07:45 AM)snippsat Wrote: Try to use code tags and not images with code,look at BBCode.
In my example i am running the last part in interactive shell has>>>
.
Now you have put all in one function and that will not work as i have written it.
Here a example running as a script,see that needprint()
when running as a script.
def line_concat(lst): temp = zip(lst[::2], lst[::-2]) return [':'.join(i) for i in temp] def file_read(file_in): with open(file_in) as f: lst = [line.strip() for line in f if not line.isspace()] return lst if __name__ == '__main__': file_in = 'xy.txt' lst = file_read(file_in) print(lst) # Test file read for line in line_concat(lst): print(line)
Output:['xxx.xxx.xx.xx', 'yyyy', 'xxx.xxx.xx.xx', 'yyyy'] xxx.xxx.xx.xx:yyyy xxx.xxx.xx.xx:yyyyxy.txt
that i use to test with is:
Output:xxx.xxx.xx.xx yyyy xxx.xxx.xx.xx yyyy
Here is what I've got. The file, when I open it, is unchanged from before I added the code.
Thank you for the help so far, this stuff can just get confusing
Heres the code now:
Quote:def line_concat(lst): temp = zip(lst[::2], lst[::-2]) return [':'.join(i) for i in temp] def file_read(file_in): with open(file_in) as f: lst = [line.strip() for line in f if not line.isspace()] return lst if __name__ == '__main__': with open("ScrapedProxys.txt","w+") as t: t.close() main() file_in = "ScrapedProxys.txt" lst = file_read(file_in) for line in line_concat(lst): f.write(line) Clear() input("Press Enter to Exit")
The
Quote:with open("ScrapedProxys.txt","w+") as t:is to create the file on start