我正在运行一些 python 代码并得到一个错误:
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1413, in __call__
return self.func(*args)
File "multiline14.py", line 28, in getText
if encodinghex in process:
TypeError: argument of type 'function' is not iterable
我的定义如下。
def gui(item):
def default_encode(s):
pass
# map items from menu to commands
encodinghex = '.encode("hex")'
decodinghex = '.decode("hex")'
mapping = {"encode_b64": base64.encodestring,"encode_url": urllib.quote_plus,"encode_hex": encodinghex, "decode_b64": base64.decodestring, "decode_url": urllib.unquote_plus, "decode_hex": decodinghex}
process = mapping.get(item, default_encode)
def getText():
#clear bottom text field
bottomtext.delete(1.0, END)
#var equals whats in middle
var = middletext.get(1.0, 'end-1c')
#insert encoded var in bottom
if encodinghex in process:
var = '"%s"' % (var)
bottomtext.insert(INSERT, eval(var + process))
elif decodinghex in process:
var = '"%s"' % (var)
bottomtext.insert(INSERT, eval(var + process))
else:
bottomtext.insert(INSERT, process(var))
是什么导致了这个错误?