# 示例代码:使用 ord() 函数
# ord() 函数用于获取字符的 Unicode 码位(integer representing the Unicode code point)
# 例如,获取字符 'A' 的 Unicode 码位
char = 'A'
unicode_code_point = ord(char)
print(f"字符 '{char}' 的 Unicode 码位是: {unicode_code_point}")
# 再举一个例子,获取字符 '中' 的 Unicode 码位
char = '中'
unicode_code_point = ord(char)
print(f"字符 '{char}' 的 Unicode 码位是: {unicode_code_point}")
ord() 函数接收一个字符(长度为1的字符串)作为参数,并返回该字符对应的 Unicode 码位。上一篇:python print()
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站