ASCII Code Conversion Table

  • Share this:

Code introduction


This function converts each character in the input string to its corresponding ASCII code and formats the output.


Technology Stack : String processing

Code Type : String processing

Code Difficulty : Intermediate


                
                    
def ascii_table(text):
    """
    将输入的字符串转换为ASCII字符画表。
    """
    ascii_art = ""
    for char in text:
        ascii_art += f"{ord(char):4} - {char}\n"
    return ascii_art