ASCII Character Frequency Table

  • Share this:

Code introduction


This function takes a string as input and returns a dictionary. The dictionary contains each character in the string and the number of times it appears.


Technology Stack : string, dictionary

Code Type : Function

Code Difficulty :


                
                    
def ascii_table(text):
    """
    输出给定文本的ASCII字符表格。
    """
    ascii_table = {}
    for char in text:
        if char in ascii_table:
            ascii_table[char] += 1
        else:
            ascii_table[char] = 1
    return ascii_table

# JSON representation