ffe*_*tte 16
我想你正在寻找codepoint. 从文档:
codepoint(c::AbstractChar) -> Integer返回与字符对应的 Unicode 代码点(一个无符号整数)
c(如果 c 不代表有效字符,则抛出异常)。对于Char,这是一个UInt32值,但AbstractChar仅表示 Unicode 子集的类型可能会返回不同大小的整数(例如UInt8)。
例如:
julia> codepoint('a')
0x00000061
Run Code Online (Sandbox Code Playgroud)
要获得与 Pythonord函数完全相同的函数,您可能需要将结果转换为有符号整数:
julia> Int(codepoint('a'))
97
Run Code Online (Sandbox Code Playgroud)
你也可以这样做:
julia> Int('a')
97
Run Code Online (Sandbox Code Playgroud)
如果你有一个字符串:
julia> s="hello";
julia> Int(s[1])
104
julia> Int(s[2])
101
julia> Int(s[5])
111
Run Code Online (Sandbox Code Playgroud)
更多细节在这里。
| 归档时间: |
|
| 查看次数: |
744 次 |
| 最近记录: |