You can download this code by clicking the button below.
This code is now available for download.
Converts a given Unicode code point to its corresponding ASCII character. If the code point cannot be directly converted to an ASCII character, it returns a question mark.
Technology Stack : String, encoding
Code Type : String processing
Code Difficulty : Beginner
def achr(codepoint, encoding='utf-8'):
"""
将Unicode码点转换为对应的ASCII字符。
"""
try:
return bytes([codepoint]).decode(encoding)
except UnicodeDecodeError:
return '?'