【发布时间】:2015-12-30 01:38:38
【问题描述】:
我正在尝试完成这项任务:
这就是我所拥有的,我在 >
上遇到语法错误粘贴代码:
# Specify where the input and output file is
InputFile = open('C:\Python\unsorted_fruits.txt', 'r')
OutputFile = open('C:\Python\sorted_fruits.txt', 'w')
# Read the input file
Fruits = InputFile.readlines()
# Sort the items in the list
Fruits.sort()
# Remove the blank lines and write the file
for fruit in Fruits:
if fruit <>"\n": # if fruit is blank, skip the write
OutputFile.write(fruit) # otherwise write the fruit to the output file
# Close the input and output file
InputFile.close()
OutputFile.close()
【问题讨论】:
-
if fruit <>"\n":你到底在做什么? -
哦,是这样的吗?什么语言使用它?
-
<>不像!=的某些已弃用语法
标签: python syntax-error