如何修改wx.StaticText中的字符串?

How to Modify a String in wx.StaticText?

我有一个元组:('a',1)

当我用wx.StaticText显示的时候,总是这样显示:('a',1)

如何让它显示成这样:(a,1) ?

注意:必须是元组。出于某种原因,当我将字符串设置为元组时,它总是与引号一起记录。所以:

a = (str(hello),1)

如果你打印 a 你会得到:

>>>print a
('hello',1)

不是直接传递元组对象,而是传递一个格式化的字符串:

>>> a = ('a', 1)

使用% operator

>>> '(%s, %s)' % a
'(a, 1)'

>>> '%s, %s' % a  # without parentheses
'a, 1'

使用str.format

>>> '({0[0]}, {0[1]})'.format(a)
'(a, 1)'
>>> '({}, {})'.format(*a)
'(a, 1)'

>>> '{0[0]}, {0[1]}'.format(a)   # without parentheses
'a, 1'
>>> '{}, {}'.format(*a)          # without parentheses
'a, 1'