You can download this code by clicking the button below.
This code is now available for download.
This function takes a string as input and prints the ASCII code and corresponding character for each character in the string.
Technology Stack : Python built-in functions, dictionaries, list comprehensions
Code Type : Function
Code Difficulty : Advanced
def ascii_table(string):
"""
打印输入字符串的ASCII表。
"""
table = {ord(char): char for char in string}
for key in sorted(table.keys()):
print(f"{key}: {table[key]}")