python將代碼轉換成網頁__python

來源:互聯網
上載者:User
import os;f_in = open("hello.cpp", "r")print "file name is: ", f_in.namef_out = open("hello2_v2.html", "w")f_out.write("<html>\n<body>\n<pre>\n")for line in f_in:    #line = line.strip('\n')    line = line.replace("<", "<")    line = line.replace(">", ">")    print line,    #f_out.write(line+"\n")    f_out.write(line)f_out.write("</pre>\n</body>\n<html>")f_in.close()f_out.close()


import os;f_in = open("hello.cpp", "r")print "file name is: ", f_in.namef_out = open("hello_table.html", "w")f_out.write("<html>\n<body>\n")# add formf_out.write("<form id=\"comment_form\" style=\"display:none\"><textarea name=\"comments\"></textarea><br \><input type=\"submit\"></form>")f_out.write("<table>\n<tbody>\n")line_num = 0for line in f_in.readlines():    line_num = line_num + 1    line = line.strip('\n')    line = line.replace("<", "<")    line = line.replace(">", ">")        f_out.write("<tr onclick=\"document.getElementById(")    f_out.write("\'comment_form\'")    f_out.write(").style.display=\'block\';\"><td> ")    f_out.write(str(line_num) + " ")    f_out.write("</td><td>")        f_out.write(line+"\n")    f_out.write("</tr></td>")f_out.write("</tbody>\n</table>\n</body>\n<html>")f_in.close()f_out.close()



相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.