Reputation: 15
def OnClick(self,event):
print "a:", a
os.system('iperf -s -w a')
Here a is displayed correctly. But in the os.system
command the value of a is taken as 0.
Could you please help me on this?
Upvotes: 0
Views: 620
Reputation: 485
os.system('iperf -s -w a')
takes literal a and not the value of the variable. I would use:
cmd = 'iperf -s -w %d' %a
os.system (cmd)
Refer input output formatting in python
Upvotes: 0
Reputation: 239453
You are not passing the value of a
, but you are passing a
as it is. So, you might want to do this
os.system('iperf -s -w {}'.format(a))
Now, the value of a
will be substituted at {}
. You can see the difference between both the versions by printing them
print 'iperf -s -w {}'.format(a)
print 'iperf -s -w a'
Upvotes: 2