Skip to content

Instantly share code, notes, and snippets.

@2439905184
Created May 24, 2023 12:58
Show Gist options
  • Save 2439905184/3d1e41761d179f4f18fd94126cee18c2 to your computer and use it in GitHub Desktop.
Save 2439905184/3d1e41761d179f4f18fd94126cee18c2 to your computer and use it in GitHub Desktop.
txt转html(p标签)
f_in = open("test.txt","r",encoding="utf-8")
f_out = open("test.html","w+",encoding="utf-8")
for line in f_in.readlines():
line_list = list(line)
line_list.insert(0,"<p>")
line_list.insert(len(line_list),"</p>")
final_line = "".join(line_list)
f_out.write(final_line+"\n")
f_in.close()
f_out.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment