我是Python3的傻瓜。我广泛地寻找问题的解决方案,但是我不明白为什么方法.seek()不能工作。 我想做一个程序,把一个档案的信息复制到另一个档案的最后一个。我知道为什么我会用其他的方法。在
提前谢谢。在
from sys import argv
script, from_file, to_file=argv
print(f"Are you sure that you want to copy {from_file} to {to_file}?")
print("Ready hit RETURN to continue, CTRL-C to abort")
input()
origin_file=""
final_file=""
try:
file1=open(from_file,'r')
file2=open(to_file,'r+')
file1=file1.read()
except:
print('There is not a file')
file2.seek(0,2)
file2.write(file1)
print(final_file)
已解决:无法对字符串对象使用seek::)
Python中的String对象没有seek函数。也许你试着找文件。你打开了两个文件file1和file2。你可以试试文件2。只要试试
file2.seek(0,2)
相关问题 更多 >
编程相关推荐