Advertisement
obernardovieira

(CGI) Read text file ( .txt ) and add new lines

Jan 13th, 2015
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.23 KB | None | 0 0
  1. #!C:\Python34\python.exe
  2.  
  3. import cgi, cgitb, sys
  4. cgitb.enable()
  5. print("Content-type: text/html")
  6. print()
  7.  
  8.  
  9. myfile = open("file.txt","r")
  10. text = myfile.read()
  11. newtext = text.replace("\n","<br/>")
  12. myfile.close()
  13.  
  14.  
  15. print(newtext)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement