wxpython: How to remove a null byte from the string when using textcontrol.GetValue ()


Objective: Use two textcontrol boxes, one as an input and one as an output However there is an additional step in the process, which fails likely because textcontrol.GetValue() returns null byte in addition

So say I have

self.tc1 = wx.TextCtrl(panel)

self.tc2 = wx.TextCtrl(panel)

and I go about it

cmd = self.tc1.GetValue()

How do I exclude last character of string cmd (or any null byte)


TypeError: execv() argument 1 must be encoded string without NULL bytes, not str

Just figured it out,

I had to change it to

cmd = self.tc1.GetValue().encode('ascii')