New file in same directory as input file . Python

2019-03-03 23:37发布

enter image description here

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 . . .:

enter image description here enter image description here

0条回答
登录 后发表回答