- 博客(2)
- 收藏
- 关注
原创 python.reverse()函数用的坑之没有返回值
问题描述: >>> ls=[1,2,3,4] >>> l2=ls.reverse() >>> print(l2) None 原因分析: reverse()没有返回值,只能改变了ls这个列表 解决方案: 所以我先用l1保存ls的值,再reverse ls,就可以得到反转后的列表 >>> ls=[1,2,3,4] >>> l1=ls >>> ls.reverse() >>>
2021-02-22 09:55:40
2197
2
原创 【UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0xad】python读取文件时的bug
项目场景: 读取文件的时候,已经加了encoding=‘gdk’,依旧报错 with open('C:\\Users\\huawei\\Desktop\\city.txt','r',encoding='gbk') as fo: fo.read() print(fo) 问题描述: 报错情况如下: UnicodeDecodeError: 'gbk' codec can't decode byte 0xad in position 34: illegal multibyte sequence
2021-02-21 15:02:21
329
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人