Created
May 24, 2023 12:58
-
-
Save 2439905184/3d1e41761d179f4f18fd94126cee18c2 to your computer and use it in GitHub Desktop.
txt转html(p标签)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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