擅长:python、mysql、java
<p>假设输入数据位于名为'输入文件.txt'在与Python代码相同的文件夹中,并且它是用UTF-8编码的。你知道吗</p>
<pre><code># Open the input file for reading.
with open('inputfile.txt', mode='r', encoding='utf-8') as infile:
# Store all the data from the input file in a variable named
# 'inlines'. This only makes sense if you have a small amount
# of data, as you suggest you do.
inlines = infile.readlines()
# Open or create a file named 'outputfile.txt' in the same folder as
# 'inputfile.txt' with UTF-8 encoding.
with open('outputfile.txt', mode='w', encoding='utf-8') as outfile:
# Walk each line in the input file.
for line in inlines:
# Write each input line to the output file with 'Return'
# removed.
outfile.write(line.replace('Return', ''))
</code></pre>