问题
import sys,os
name_list = open(sys.argv[1]).read().split('\r')
os.remove(sys.argv[1])
input_file = (sys.argv[2])
def Extractor(input,output='query.txt'):
query = open(input,'r').read().split('\r')
dir,file=os.path.split(input)
temp_out= os.path.join(dir,output)
out_file=open(temp_out,'w')
print Extractor(input_file)
I have no idea why this isn't working . . .
i am trying to create a new file in the same directory as the input file but it is saying that there is an error . i'm not used to working in Automator's workflow but theoretically this should work since i've used this in python interpreters .
input_file = (sys.argv2) is a string of the file location . when i print the query inside of the function it works fine but once i get to "dir,file = os.path.split(input)" that's where the function fails .
Why isn't this working ?
Error message from Automator isn't telling me much . . .:
来源:https://stackoverflow.com/questions/18970231/new-file-in-same-directory-as-input-file-python