简体   繁体   English

尝试使用Python从一个文本文件复制到另一个文本文件

[英]Trying to copy from one text file to another in Python

I attempted to use the code below, but all I get is that I need exactly 1 argument, but I gave 0. 我尝试使用下面的代码,但是得到的只是我需要1个参数,但我给出了0。

print "Copy one file into another:"

print "Type first file here:" 

file1 = raw_input('>')

openfile = open(file1).read()

file2 = raw_input('>')

open2file = open(file2, 'w')
second = open2file.write() 


print "All Done"

It's open2file.write(openfile) . 它是open2file.write(openfile) This sends the content of the file you read into the opened file. 这会将您读取的文件内容发送到打开的文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM