HTML Special Characters Encoding Function

  • Share this:

Code introduction


This function takes an input string and uses the escape function from the html library to encode HTML special characters, returning the encoded string.


Technology Stack : html

Code Type : String processing

Code Difficulty : Beginner


                
                    
import random
import os
import re
import json
import math
import datetime
import hashlib
import base64
import html

def encode_html(input_string):
    """
    将输入字符串中的HTML特殊字符进行转义编码
    """
    return html.escape(input_string)                
              
Tags: