Python中的ASCII转换

2024-04-18 18:37:31 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在做一个加密程序,如果我能用ascii数字来表示一个字符,那么这个程序就很容易实现字符串.翻译)有没有一种方法可以将一个字符通过其ascii数字,然后将其附加到字符串中?你知道吗


Tags: 方法字符串程序ascii数字字符
1条回答
网友
1楼 · 发布于 2024-04-18 18:37:31

我想你在找^{}

Return a string of one character whose ASCII code is the integer i. For example, chr(97) returns the string 'a'. This is the inverse of ord(). The argument must be in the range [0..255], inclusive; ValueError will be raised if i is outside that range. See also unichr().

^{}

Given a string of length one, return an integer representing the Unicode code point of the character when the argument is a unicode object, or the value of the byte when the argument is an 8-bit string.

示例:

print("somestring" + chr(65)) # prints "somestringA"

相关问题 更多 >