python报错之 AttributeError: ‘list‘ object has no attribute ‘replace‘
a = ['a-b'] b = a.replace('-','') print(b)
报错:
AttributeError: 'list' object has no attribute 'replace'
原因:
list对象没有replace方法,str对象才有。
解决方案:
a = ['a-b'] b = str(a).replace('-','') print(b)
》》['ab']
完美解决!
python报错之 AttributeError: ‘list‘ object has no attribute ‘replace‘相关推荐
- Python报错: AttributeError: ‘Spider2107Pipeline‘ object has no attribute ‘wb‘
import openpyxlclass Spider2107Pipeline:def __int__(self):self.wb = openpyxl.Workbook()self.ws = sel ...
- Pycharm报错:AttributeError: ‘NoneType‘ object has no attribute ‘_gdal‘的解决办法
Pycharm报错:AttributeError: 'NoneType' object has no attribute '_gdal'的解决办法 解决办法如下: pycharm找到settings ...
- tensorflow报错:AttributeError: 'module' object has no attribute 'get_or_create_global_step'
Tensorflow 1.0训练官方教程中CIFAR10例子 官方教程 执行 python cifar10_train.py时 报错: AttributeError: 'module' objec ...
- python2 中使用pip2 install package_name的时候报错:AttributeError: ‘int‘ object has no attribute ‘endswith‘
1 错误说明 1.在python2的环境下使用pip2 install安装库包的时候报错:AttributeError: 'int' object has no attribute 'endswith ...
- Pytorch报错:AttributeError: ‘version_info‘ object has no attribute ‘__version__‘
代码莫名报错:AttributeError: 'version_info' object has no attribute '__version__' 解决:pip install pyparsing ...
- Tensorflow报错:AttributeError: 'module' object has no attribute 'scalar_summary'
报错: tf.scalar_summary(l.op.name + ' (raw)', l) AttributeError: 'module' object has no attribute 'sca ...
- keras模型训练报错: AttributeError: 'list' object has no attribute 'set_model'
错误信息: AttributeError: 'list' object has no attribute 'set_model' 根据错误提示:错误代码位于如下 model.fit(X_train, ...
- Jetson Nano【13】关于torch2trt报错:AttributeError: ‘Tensor‘ object has no attribute ‘_trt‘的一种可能性
尝试转换,报错,日志如下 AttributeError Traceback (most recent call last) <ipython-input-24-0cf9bfd4fe52> ...
- 解决file.seek()读取文件报错:AttributeError: ‘str‘ object has no attribute ‘seek‘
解决方法 可能性1:调整代码,确保传给file.seek()中file是python的文件类,即File类型,而不是一个字符串. 可能性2:这个文件在其他地方打开,没有关闭(感谢@weixin_472 ...
最新文章
- spring JdbcTemplate 在项目中的浅层(5个使用场景)封装
- SQL查询四舍五入 解决方法
- pytorch kl散度学习笔记
- windows10 系统设置一键备份
- boost::ratio_abs相关的测试程序
- JQuery选择器中的子元素选择器
- mui ajax 传递base64,HTML5 MUI 手机预览图片,裁剪上传base64,保存数据库
- 笔记本电脑没有鼠标怎么右键_联想笔记本电脑没有声音怎么修复
- Oracle 10g ORA-12154: TNS: could not resolve the connect identifier specified 问题解决!
- Docker下redis的主从配置
- 中央民族大学计算机专业研究生,信息工程学院
- domain name
- DWM1000开启后TX、RX、SFD、RXOK均不亮的原因
- 数字电路基础-逻辑门电路
- 两万字详解自动驾驶开发工具链的现状与趋势
- 泛微云桥e-Bridge-任意文件读取漏洞
- 约瑟夫问题、约瑟夫环
- 因果分析:原理、方法论、应用
- mybatis插入数据到sqlserver报异常The statement must be executed before any results can be obtained.
- Percent百分比布局用法
热门文章
- 单片机拟真电路图软件_基于MSP430单片机设计的高效数控直流电源及其测试方法与流程...
- python 入门学习教程笔记-- BMR 计算器
- 二相混合式步进电机开环细分控制simulink建模仿真含模型文件
- 【Proteus仿真】uln2003驱动二相四线制步进电机正转
- SpringBoot 定时任务的实现
- android多线程下载3
- 常用的文件类型有哪些?有什么类型,属于什么文件?
- 什么是CMS?企业开发使用什么CMS?
- cake fork什么意思_Fork 是什么意思?
- 接口定义,常见的接口,常见的接口请求方式,put请求和patch请求的区别