ASCII Code Table of Given Text

  • Share this:

Code introduction


This function takes a string as input and returns a dictionary where the keys are the characters in the string and the values are their corresponding ASCII codes.


Technology Stack : String, Dictionary, built-in function ord()

Code Type : Function

Code Difficulty : Beginner


                
                    
def ascii_table(text):
    """
    打印给定文本的ASCII码表。
    """
    result = {}
    for char in text:
        result[char] = ord(char)
    return result