linux - Redirecting output to file in Python script -


i have python(version 2.6.6) script below:

import subprocess  id = 834 urllink = "https://xyzm:8443/rest/import-job/" + str(id) subprocess.call([     'curl',     '-k',     '-u',     'xxxx:abc',     '-x',     'get',     urllink ]) 

it returns json output terminal. how can redirect output file, can parse file , use same file(data) while executing post command?

any reply appreciated.

thanks, jee

the following code write file in python 2.6 (i have set write contained in output variable), followed read of same file & print command display output on terminal.

# write file out_file = open("test.txt", "w") out_file.write(output) out_file.close()  # read file in_file = open("test.txt", "r") text = in_file.read() in_file.close()  print text 

Comments