读取D:\2023training\file02.txt,写入到D:\2023training\file02_copy.txt。
时间: 2023-08-15 13:09:34 浏览: 79
读取和写入.txt
好的,请稍等。
```python
file_path = r'D:\2023training\file02.txt'
copy_file_path = r'D:\2023training\file02_copy.txt'
with open(file_path, 'r') as file:
content = file.read()
with open(copy_file_path, 'w') as copy_file:
copy_file.write(content)
print("文件复制完成。")
```
这段代码会将 `D:\2023training\file02.txt` 中的内容复制到 `D:\2023training\file02_copy.txt` 中。
阅读全文