def readfile(filename,mode="rt"):
head = "<li><a href="""
center =""" target="_blank">"""
end ="<br></a></li>"
with open(filename,mode) as fin:
for line in fin:
link = line
length_link = len(link)
twitter_name_after = link[twitter_name_before+5:]
full_code = head+link+center+"@"+twitter_name_after+end
writefile("C:/Users/Johny The Overlord/Documents/Code/test_1.txt",full_code)
def writefile(filename,contents,mode="wt"):
with open(filename,mode) as fout:
fout.write(contents)
def main():
# my code here
readfile("C:/Users/Johny The Overlord/Documents/Code/test.txt")
if __name__ == "__main__":
main()
url in text1 https://twitter.com/xxx https://twitter.com/yyy https://twitter.com/zzz
in text2 should have
https://twitter.com/xxx target="_blank">@xxx https://twitter.com/yyy target="_blank">@yyy https://twitter.com/zzz target="_blank">@zzz
but it only write last url. how do I fix?