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的更多相关文章
- string.trim().length()的用法
public class Test{ public static void main(String args[]){ String data = " a bc "; //调用str ...
- 关于string的length
在C++里面,std::string的length()返回的是字节数,与编码方式有关. int main() { std::string s = "我是中国人"; std::cou ...
- 使用xadmin更新数据时,报错expected string or bytes-like object
expected string or bytes-like object 期望的字符串或类似字节的对象,一般为数据类型不匹配造成 本人在实际项目里发现的问题是: 数据库里的字段类型与django里mo ...
- 解决:error: Cannot fetch repo (TypeError: expected string or buffer)
同步源码,问题重现: Fetching project platform/external/libopus Fetching project repo error: Cannot fetch repo ...
- WCF常见异常-The maximum string content length quota (8192) has been exceeded while reading XML data
异常信息:The maximum string content length quota (8192) has been exceeded while reading XML data 问题:调用第三 ...
- The maximum string content length quota (8192) has been exceeded while reading XML data
原文:The maximum string content length quota (8192) has been exceeded while reading XML data 问题场景:在我们W ...
- String.length()和String.getBytes().length
1.字符与字节 抛出如下代码: public static void main(String[] args) { String str = "活出自己范儿"; System.out ...
- TypeError: sequence item 0: expected string, Tag found
原始代码: soup = BeautifulSoup(result, 'html.parser') content_list = soup.find_all('p', attrs={"cla ...
- [Python]json对象转换出错expected string or buffer python
[问题] 今天在使用python中的json转换碰到一个问题: 错误显示: expected string or buffer json内容如下: {u'err_no': 0, u'corpus_no ...
随机推荐
- 【mysql】编码问题
原始数据是unicode,存入数据库.需要注意的几个地方: 1.建立数据库时,选择编码方式为utf8 -- UTF-8 Unicode 2.代码中建立数据库连接时,选择charset=utf8 3.存 ...
- laravel 更新
public function update(Request $request, ResponseFactoryContract $response) { $user = $request->u ...
- 小学生都看得懂的C语言入门(4): 数组与函数
// 之前判断素数, 只需要到sqrt(x)即可,//更加简单的, 判断能够比已知的小于x的素数整除, 运行更快 #include <stdio.h> // 之前判断素数, 只需要到sqr ...
- bzoj 1076
发现自己已经把期望dp忘光了... 其实本质上非常简单,就是利用状压的思想跑期望 首先很容易设计出状态:记状态f[s][i]表示到了第i个点,之前已选过的点的状态为s时所能获得的最大期望得分 但是会发 ...
- java获取当前时间精确到毫秒
转载:http://af8991.iteye.com/blog/1217672 import java.text.SimpleDateFormat; import java.util.Date; im ...
- 任务超时退出的方法 C#
超出时间方法退出.防止卡住. 方法: private static bool ImportTaskTimeout(Action method, int hours) { try { var task ...
- SRS流媒体服务器搭建+ffmpeg推流VLC取流观看
一.编译SRS https://github.com/winlinvip/simple-rtmp-server 目前有1.0-release.2.0.3.0等版本 2.0官方文档地址:https:// ...
- IT设备服务监控的方法论
有方法论提导,在技战术方面才不会偏离目录. 使用服务级别作为关键语,召示着承诺和责任. https://www.circonus.com/2018/06/comprehensive-container ...
- 一脸懵逼学习Struts数据校验以及数据回显,模型驱动,防止表单重复提交的应用。
1:Struts2表单数据校验: (1)前台校验,也称之为客户端校验,主要是通过Javascript编程的方式进行数据的验证. (2)后台校验,也称之为服务器校验,这里指的是使用Struts2通过xm ...
- google 插件
鼠标手势 crxMouse Chrome™ Gestures Google翻译 json格式化 JSONView github展开文件夹 Octotree axure 原型 Axur ...