我是批量初学者。我想使用 fc 比较for循环中的两个文本文件。我写了以下代码:
'fc' is not recognized as an internal or external command,
operable program or batch file.
我收到错误:
try:
myFile=open("zipcodes.txt") #Tries to open file user entered
except:
print "File can't be opened:", myFile #If input is invalid filename, print error
exit()
zipcode = dict() #List to store individual sentences
line = myFile.readline() #Read each line of entered file
ask = raw_input("Enter a zip code: ")
if ask not in line:
print "Not Found."
else:
for line in myFile:
words = line.split()
if words[2] == ask:
zipcode = words[0:2]
for value in zipcode:
print value,
当我在循环外执行时,一切正常。这里的问题是什么?