| 
 | 
 
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册  
 
x
 
- f1 = open('OpenMe.mp3')
 
 - f2 = open('OpenMe.txt', 'x')        # 使用”x”打开更安全
 
 - f2.write(f1.read())
 
 - f2.close()
 
 - f1.close()
 
 
  复制代码 
请问一下。 
f2.write(f1.read()) 为什么写出 f2.write(f1.read(size=-1)) 会报错  size为给定或给定负值的时候 不都是读取剩余的所有字符吗 
 
Traceback (most recent call last): 
  File "E:/python/学习中保存的文件/1-28.py", line 3, in <module> 
    f2.write(f1.read(size = -1)) 
TypeError: read() takes no keyword arguments 
这个是改完之后的报错
你要用-1的话可以这么写。我测试过是可以的,python3  
- f1 = open('OpenMe.mp3')
 
 - f2 = open('OpenMe.txt', 'x')        # 使用”x”打开更安全
 
 - f2.write(f1.read(-1))
 
 - f2.close()
 
 - f1.close()
 
 
  复制代码 
 
 
 |   
 
 
 
 |