ord() expected string of length 1, but int found

Posted kailicard

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ord() expected string of length 1, but int found相关的知识,希望对你有一定的参考价值。

源代码是这样:

s=b‘^SdVkT#S ]`Y\\!^)\x8f\x80ism‘
key=‘‘
for i in s:
     i=ord(i)-16
     key+=chr(i^32)
print (key)

运行后出现了问题:ord() expected string of length 1, but int found

之所以出现这个问题,是在字符串转换过程中出现了一个小错误,在一系列百度和谷歌后,发现概念还是很迷糊,但是在曙光大佬的解答后,明白了怎么处理,就是在s后加””,运行后发现完美解决

以上是关于ord() expected string of length 1, but int found的主要内容,如果未能解决你的问题,请参考以下文章

Input ‘filename‘ of ‘ReadFile ‘Op has type float32 that does not match expected type of string

排查Hive报错:org.apache.hadoop.hive.serde2.SerDeException: java.io.IOException: Start of Array expected(

CORE EF The expected type was 'System.String' but the actual value was of type 'System.G

在springboot启动报错:No qualifying bean of type 'javax.sql.DataSource' available: expected at lea

Error: Expected resource of type xxx [ResourceType]

Law of Iterated Expectations & Covariance