python seek()方法报错:“io.UnsupportedOperation: can't do nonzero cur-relative seeks”
今天使用seek()时报错了, 看下图
然后就百度了一下,找到了解决方法
这篇博客https://www.cnblogs.com/xisheng/p/7636736.html 帮忙解决了问题,
照理说,按照seek()方法的格式file.seek(offset,whence),后面的1代表从当前位置开始算起进行偏移,那又为什么报错呢?
这是因为,在文本文件中,没有使用b模式选项打开的文件,只允许从文件头开始计算相对位置,从文件尾计算时就会引发异常。将 f=open("aaa.txt","r+") 改成
f = open("aaa.txt","rb") 就可以了
python seek()方法报错:“io.UnsupportedOperation: can't do nonzero cur-relative seeks”的更多相关文章
- 使用seek()方法报错:“io.UnsupportedOperation: can't do nonzero cur-relative seeks”错误的原因
在使用seek()函数时,有时候会报错为 “io.UnsupportedOperation: can't do nonzero cur-relative seeks”,代码如下: >>& ...
- 在使用seek()函数时,有时候会报错为 “io.UnsupportedOperation: can't do nonzero cur-relative seeks”,代码如下:
__author__ = 'ZHHT' #!/usr/bin/env python # -*- coding:utf-8 -*- import os f = open("test1" ...
- appium+python自动化64-使用Uiautomator2执行driver.keyevent()方法报错解决
前言 未加'automationName': 'Uiautomator2'参数使用Uiautomator可以正常使用driver.keyevent()方法,使用Uiautomator2时driver. ...
- 项目实体类使用@Data注解,但是项目业务类中使用getA(),setA()方法报错,eclipse中配置lombok
@Data注解来源与Lombok,可以减少代码中大量的set get方法,大量减少冗余代码,但是今天部署项目时候,发现实体类使用@Data注解,但是项目业务类中使用getA(),setA()方法报错. ...
- eclipse中运行 main 方法报错,找不到类
eclipse (maven 项目)中运行 main 方法报错,找不到类 ** 发现:在 eclipse中的 "Marker" 控制面板中 ,发现问题所在 只要删除 maven 仓 ...
- Android webview js 调用java方法报错"Uncaught TypeError: Object [object Object] has no method xx
webview开发,在Android4.4下js调用java方法报错"Uncaught TypeError: Object [object Object] has no method,同样的 ...
- moviepy AudioClip的max_volume方法报错ValueError: operands could not be broadcast together with shapes(2,)
☞ ░ 前往老猿Python博文目录 ░ 在<moviepy音视频剪辑:AudioClip的max_volume方法报TypeError: bad operand type for abs(): ...
- SpringBoot关于SpringDataJpa中findOne()方法报错问题
问题描述: 首先用的SpringDataJPA的1.11版本,可以使用findOne()方法根据id查询 然后我使用了2.0.5版本,发现findOne()方法报错了,不能用来当作根据id查询了. 当 ...
- Python -- seek定位文件指针位置 错误 io.UnsupportedOperation: can't do nonzero cur-relative seeks错误
f=open("E:/test/悯农.txt",'r') str=f.read(17) print("读取的数据是:",str) position=f.tell ...
随机推荐
- pyqt5-对文本样式进行操作
self.label_2 = QtWidgets.QLabel(self.centralWidget) self.label_2.setGeometry(QtCore.QRect(330, 220, ...
- websocketd
https://www.cnblogs.com/tinywan/p/6826125.html https://www.jianshu.com/p/63afd0099565
- Linux 命令locate
原文:https://blog.csdn.net/liang19890820/article/details/53285624 简述 locate 可以很快速的搜寻档案系统内是否有指定的档案.其方法是 ...
- (1.12)SQL优化——mysql表名、库名大小写敏感
mysql表名.库名大小写敏感 关键词:mysql大小写敏感
- centos删除用户出错userdel: user xxx is currently used by process 23750
今天ytkah管理centos用户准备删除某个用户时出错了,提示userdel: user xxx is currently used by process 23750,这是因为xxx用户还在登陆中, ...
- 【环境配置】配置jdk
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/manoel/article/details/37736569 1. 下载jdk的安装文件 http: ...
- RadioButton使用
RadioButton和CheckBox差不多,这里只写一个,因为我本身不是学andorid,所以就当给自己留一个备份,省的每次用到都需要代码敲一次,很麻烦 1.如果想选中时想改变颜色可以设置一个xm ...
- OC相机封装
AlbumService询问相机权限 AuthorizationService相机封装 plist文件设置: <key>NSCameraUsageDescription</key&g ...
- HP1020打印机“传递给系统调用的数据区域太小” 如何处理?
如果电脑上曾经安装过 HP LaserJet 激光打印机的驱动程序,重新安装驱动程序之前,需要完全卸载以前安装的驱动程序,否则可能会出现无法找到设备或者安装不上驱动程序的现象. 安装网站下载的即插即用 ...
- react img 被自动转成base64,无法根据当前路径来动态改变值的解决办法
项目需求,需要根据当前的图片的路径值的来(加或者减)动态改变其值: state定义如下: this.state={ basket01:0+require("../../img/egg/egg ...