0
点赞
收藏
分享

微信扫一扫

ValueError: could not convert string to float: '\ufeff\n'

python读取文件(下图为部分截图),行内容有交易金额,也有其它内容

ValueError: could not convert string to float:

 

过滤掉非交易金额行:if not i.startswith("2023") and i.strip()!="\n" and not i.startswith("退"):

对交易金额行进行强转float做统计

但是有特殊字符行,所以报如下错:

ValueError: could not convert string to float:

 

解决方案:过滤前,去除字符即可,i.strip('\ufeff')

 

__EOF__

本文作者:持之以恒(韧)
关于博主:擅长性能、全链路、自动化、企业级自动化持续集成(DevOps/TestOps)、测开等



举报

相关推荐

0 条评论