Reputation:
myfile = open("wrsu"+str(i)+'_'+str(j)+'_'+str(TimesToExec)+".txt",'w')
sys.stdout = myfile
p1 = subprocess.Popen([pathname,"r", "s","u",str(i),str(j),str(runTime)],stdout=subprocess.PIPE)
output = p1.communicate()[0]
print output,
When I use this to redirect the output of a exe to my own file, it always
a carriage return after each line, How to suppress it?
Upvotes: 2
Views: 4003
Reputation: 2123
def Popenstrip(self):
p = Popen([vmrun_cmd, list_arg], stdout=PIPE).communicate()[0]
return (line for line in p.splitlines() if line.strip())
Upvotes: 1
Reputation: 270
Here's how I removed the carriage return:
p = Popen([vmrun_cmd, list_arg], stdout=PIPE).communicate()[0]
for line in p.splitlines():
if line.strip():
print line
Upvotes: 2