Bài này chỉ đọc. Khám phá các câu trả lời và kết nối với những người sáng tạo khác trên cộng đồng. Cộng đồng.View Community Show Thông tin trong bài đăng này có thể đã lỗi thời, thay vào đó hãy xem tài liệu của chúng tôi. Xem tài liệu Tôi có thể chuyển đổi mã python thành mã HTML không? Tôi đã muốn biến mã Python của mình thành HTML để nó có thể chạy trên một trang web mà không thực sự mở mã khi tôi tải xuống dưới dạng mã nhúng từ trang web. Nếu bất cứ ai có thể tìm ra cách chuyển đổi mã chính xác thành mã HTML trong khi chỉ hiển thị đầu ra, điều đó sẽ được đánh giá cao !! Đây là mã tôi muốn chuyển đổi: 2 năm trước Cử tri
@19wintersp Mã HTML sẽ không hoạt động ... Tôi đã nhập "Seth01Master" cho @ và "Word-Bomb" cho. Bạn có thể giúp tôi không? 2 năm trước @Seth01Master Cử tri
Mã HTML sẽ không hoạt động ... Tôi đã nhập "Seth01Master" cho @ và "Word-Bomb" cho. Bạn có thể giúp tôi không? 2 năm trước @19wintersp Cử tri 2 năm trước Cử tri 2 năm trước Cử tri Tôi đang học các ngôn ngữ lập trình Python và HTML ngay bây giờ và tôi vừa học cách tạo chức năng Hello World. Bây giờ tôi muốn in chức năng này trên trang web của tôi. Tuy nhiên, việc đặt chức năng Python bên trong chương trình HTML của tôi không hoạt động. Có một số quy trình để chuyển đổi chương trình Python của tôi thành một chương trình HTML để tôi có thể hiển thị nó trên trang web của mình không? Ngoài ra, trang web của tôi dường như chỉ hoạt động trên máy tính của tôi. Tôi đã cố gắng hiển thị cho một người bạn trang web của mình, nhưng nó sẽ không tải trên máy tính của anh ấy. URL trang web của tôi là "C: \ users \ nathan \ trang web \ trang web.html" 20 ví dụ mã Python được tìm thấy liên quan đến "chuyển đổi thành HTML". Bạn có thể bỏ phiếu cho những người bạn thích hoặc bỏ phiếu cho những người bạn không thích và đi đến dự án gốc hoặc tệp nguồn bằng cách theo các liên kết trên mỗi ví dụ. convert to html". You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. ví dụ 1 def convertHtmlToPdf(self,sourceHtml, outputFilename): """ Open output file for writing (truncated binary) and converts HTML code into pdf file format :param sourceHtml: The html source to be converted to pdf :param outputFilename: Name of the output file as pdf :return: Error if pdf not generated successfully """ resultFile = open(outputFilename, "w+b") # convert HTML to PDF pisaStatus = pisa.CreatePDF(sourceHtml, dest=resultFile) # close output file resultFile.close() # return True on success and False on errors return pisaStatus.err Ví dụ 2 def convert_field_to_html(cr, table, field_name, html_field_name): """ Convert field value to HTML value. .. versionadded:: 7.0 """ if version_info[0] < 7: logger.error("You cannot use this method in an OpenUpgrade version " "prior to 7.0.") return cr.execute( "SELECT id, %(field)s FROM %(table)s WHERE %(field)s IS NOT NULL" % { 'field': field_name, 'table': table, } ) for row in cr.fetchall(): logged_query( cr, "UPDATE %(table)s SET %(field)s = %%s WHERE id = %%s" % { 'field': html_field_name, 'table': table, }, (plaintext2html(row[1]), row[0]) ) Ví dụ 3 def convert_to_html(filename): # Do the conversion with pandoc output = pypandoc.convert(filename, 'html') # Clean up with tidy... output, errors = tidy_document(output, options={ 'numeric-entities': 1, 'wrap': 80, }) print(errors) # replace smart quotes. output = output.replace(u"\u2018", '‘').replace(u"\u2019", '’') output = output.replace(u"\u201c", "“").replace(u"\u201d", "”") # write the output filename, ext = os.path.splitext(filename) filename = "{0}.html".format(filename) with open(filename, 'w') as f: # Python 2 "fix". If this isn't a string, encode it. if type(output) is not str: output = output.encode('utf-8') f.write(output) print("Done! Output written to: {}\n".format(filename)) Ví dụ 4 def convert_link_to_html(s, l, t): link_text, url = t._skipped t["link_text"] = wiki_markup.transformString(link_text) t["url"] = url return '<A href="{url}">{link_text}</A>'.format_map(t) Ví dụ 5 def convertToHTML(opening, closing): def conversionParseAction(s, l, t): return opening + t[0] + closing return conversionParseAction Ví dụ 6 def convert_file_contents_to_html(normalized_output_file): # This is the part that reads the contents of each output file linecount = 0 # file_html_string = file_html_string + " <pre>" file_html_string = " <div class=\"filedata\">" try: with open(normalized_output_file, "r") as scan_file: for line in scan_file: line = unicode(line, errors='ignore') try: sanitized = bleach.clean(line) except: print( "[!] Could not output santize the following line (Not including it in report to be safe):") print(" " + line) sanitized = "" if linecount < 300: file_html_string = file_html_string + sanitized + "<br />" linecount = linecount + 1 if linecount > 300: file_html_string = file_html_string + "\nSnip... Only displaying first 300 of the total " + str( linecount) + " lines...\n" except IOError, e: # dont tell the user at the concole that file didnt exist. pass Ví dụ 7 def convert_view_to_html(self): """Begin conversion of the view to HTML.""" for line in self.view.split_by_newlines(sublime.Region(self.pt, self.size)): self.char_count = 0 self.size = line.end() empty = not bool(line.size()) line = self.convert_line_to_html(empty) self.html.append(self.print_line(line, self.curr_row)) self.curr_row += 1 Ví dụ 8 def convert_markup_to_html(opening, closing): def conversionParseAction(s, l, t): return opening + wiki_markup.transformString(t[1][1:-1]) + closing return conversionParseAction # use a nestedExpr with originalTextFor to parse nested braces, but return the # parsed text as a single string containing the outermost nested braces instead # of a nested list of parsed tokens Ví dụ 9 def convert_html_to_markdown(html: str) -> str: parser = html2text.HTML2Text() markdown = parser.handle(html).strip() # We want images to get linked and inline previewed, but html2text will turn # them into links of the form `![](http://foo.com/image.png)`, which is # ugly. Run a regex over the resulting description, turning links of the # form `![](http://foo.com/image.png?12345)` into # `[image.png](http://foo.com/image.png)`. return re.sub("!\\[\\]\\((\\S*)/(\\S*)\\?(\\S*)\\)", "[\\2](\\1/\\2)", markdown) Ví dụ 10 def convertHtmlToPdf(self,sourceHtml, outputFilename): """ Open output file for writing (truncated binary) and converts HTML code into pdf file format :param sourceHtml: The html source to be converted to pdf :param outputFilename: Name of the output file as pdf :return: Error if pdf not generated successfully """ resultFile = open(outputFilename, "w+b") # convert HTML to PDF pisaStatus = pisa.CreatePDF(sourceHtml, dest=resultFile) # close output file resultFile.close() # return True on success and False on errors return pisaStatus.err0 Ví dụ 11 def convertHtmlToPdf(self,sourceHtml, outputFilename): """ Open output file for writing (truncated binary) and converts HTML code into pdf file format :param sourceHtml: The html source to be converted to pdf :param outputFilename: Name of the output file as pdf :return: Error if pdf not generated successfully """ resultFile = open(outputFilename, "w+b") # convert HTML to PDF pisaStatus = pisa.CreatePDF(sourceHtml, dest=resultFile) # close output file resultFile.close() # return True on success and False on errors return pisaStatus.err1 Ví dụ 12 def convertHtmlToPdf(self,sourceHtml, outputFilename): """ Open output file for writing (truncated binary) and converts HTML code into pdf file format :param sourceHtml: The html source to be converted to pdf :param outputFilename: Name of the output file as pdf :return: Error if pdf not generated successfully """ resultFile = open(outputFilename, "w+b") # convert HTML to PDF pisaStatus = pisa.CreatePDF(sourceHtml, dest=resultFile) # close output file resultFile.close() # return True on success and False on errors return pisaStatus.err2 Ví dụ 13 def convertHtmlToPdf(self,sourceHtml, outputFilename): """ Open output file for writing (truncated binary) and converts HTML code into pdf file format :param sourceHtml: The html source to be converted to pdf :param outputFilename: Name of the output file as pdf :return: Error if pdf not generated successfully """ resultFile = open(outputFilename, "w+b") # convert HTML to PDF pisaStatus = pisa.CreatePDF(sourceHtml, dest=resultFile) # close output file resultFile.close() # return True on success and False on errors return pisaStatus.err3 Ví dụ 14 def convertHtmlToPdf(self,sourceHtml, outputFilename): """ Open output file for writing (truncated binary) and converts HTML code into pdf file format :param sourceHtml: The html source to be converted to pdf :param outputFilename: Name of the output file as pdf :return: Error if pdf not generated successfully """ resultFile = open(outputFilename, "w+b") # convert HTML to PDF pisaStatus = pisa.CreatePDF(sourceHtml, dest=resultFile) # close output file resultFile.close() # return True on success and False on errors return pisaStatus.err4 Ví dụ 15 def convertHtmlToPdf(self,sourceHtml, outputFilename): """ Open output file for writing (truncated binary) and converts HTML code into pdf file format :param sourceHtml: The html source to be converted to pdf :param outputFilename: Name of the output file as pdf :return: Error if pdf not generated successfully """ resultFile = open(outputFilename, "w+b") # convert HTML to PDF pisaStatus = pisa.CreatePDF(sourceHtml, dest=resultFile) # close output file resultFile.close() # return True on success and False on errors return pisaStatus.err5 Ví dụ 16 def convertHtmlToPdf(self,sourceHtml, outputFilename): """ Open output file for writing (truncated binary) and converts HTML code into pdf file format :param sourceHtml: The html source to be converted to pdf :param outputFilename: Name of the output file as pdf :return: Error if pdf not generated successfully """ resultFile = open(outputFilename, "w+b") # convert HTML to PDF pisaStatus = pisa.CreatePDF(sourceHtml, dest=resultFile) # close output file resultFile.close() # return True on success and False on errors return pisaStatus.err6 Ví dụ 17 def convertHtmlToPdf(self,sourceHtml, outputFilename): """ Open output file for writing (truncated binary) and converts HTML code into pdf file format :param sourceHtml: The html source to be converted to pdf :param outputFilename: Name of the output file as pdf :return: Error if pdf not generated successfully """ resultFile = open(outputFilename, "w+b") # convert HTML to PDF pisaStatus = pisa.CreatePDF(sourceHtml, dest=resultFile) # close output file resultFile.close() # return True on success and False on errors return pisaStatus.err7 Ví dụ 18 def convertHtmlToPdf(self,sourceHtml, outputFilename): """ Open output file for writing (truncated binary) and converts HTML code into pdf file format :param sourceHtml: The html source to be converted to pdf :param outputFilename: Name of the output file as pdf :return: Error if pdf not generated successfully """ resultFile = open(outputFilename, "w+b") # convert HTML to PDF pisaStatus = pisa.CreatePDF(sourceHtml, dest=resultFile) # close output file resultFile.close() # return True on success and False on errors return pisaStatus.err8 Ví dụ 19 def convertHtmlToPdf(self,sourceHtml, outputFilename): """ Open output file for writing (truncated binary) and converts HTML code into pdf file format :param sourceHtml: The html source to be converted to pdf :param outputFilename: Name of the output file as pdf :return: Error if pdf not generated successfully """ resultFile = open(outputFilename, "w+b") # convert HTML to PDF pisaStatus = pisa.CreatePDF(sourceHtml, dest=resultFile) # close output file resultFile.close() # return True on success and False on errors return pisaStatus.err9 Ví dụ 20 def convert_field_to_html(cr, table, field_name, html_field_name): """ Convert field value to HTML value. .. versionadded:: 7.0 """ if version_info[0] < 7: logger.error("You cannot use this method in an OpenUpgrade version " "prior to 7.0.") return cr.execute( "SELECT id, %(field)s FROM %(table)s WHERE %(field)s IS NOT NULL" % { 'field': field_name, 'table': table, } ) for row in cr.fetchall(): logged_query( cr, "UPDATE %(table)s SET %(field)s = %%s WHERE id = %%s" % { 'field': html_field_name, 'table': table, }, (plaintext2html(row[1]), row[0]) )0 Làm cách nào để chuyển đổi tệp Python sang trang web của tôi?Biến một kịch bản Python thành một trang web.. Bước 1: Trích xuất quá trình xử lý vào một hàm .. Bước 2: Tạo một trang web .. Bước 3: Cung cấp mã xử lý có sẵn cho ứng dụng web .. Bước 4: Chấp nhận đầu vào .. Bước 5: Đầu vào xác thực .. Bước 6: Thực hiện tính toán !. Làm cách nào để hiển thị đầu ra Python trong HTML?Bạn có thể hiển thị bất kỳ nội dung nào và hoạt động với các trang động hoặc tĩnh bằng Python ... Khởi chạy Trình chỉnh sửa Python của bạn và mở tệp mã nguồn bạn muốn sử dụng để in thông tin vào trang web .. Thêm thư viện "CGITB" vào đầu tệp .. Đặt tiêu đề "loại nội dung" .. Hiển thị một đoạn mã HTML .. |