当我将一个文本文件复制到另一个文本文件时,新文件的末尾有两个字符:(??),这是我不想要的。
我在 Windows7 上使用 Python3.6.0
这是我的脚本:
from sys import argv
script, from_file, to_file = argv
#Open from_file and get the text from it
indata = open(from_file).read()
#Write the from_file text to to_file
open(to_file, 'w').write(indata)
我在 PowerShell 中运行以下命令:
>echo "This is a test file." > TestSource.txt
>type TestSource.txt
This is a test file.
>python CopyFile.py TestSource.txt TestDestination.txt
>type TestDestination.txt
This is a test file.??
为什么我创建的文件中会出现两个问号 (??)?
编辑:此相关问题被建议为重复。我的问题是当我将一个文本文件复制到另一个文本文件时 Python 的行为。这个相关问题是关于 Windows PowerShell 如何创建文本文件的。
相关分类