任何人都可以帮我解决我的问题。我是新来的蟒蛇,我不能得到如何在下列情况下,一个参数传递给一个函数: 在一个单独的文件(sentiment_analysis)我有一本字典和对象的数组:python Tkinter:将参数传递给函数
positiveSentiments = dict() // here are some words related to each of the object
objects = ['Google', 'Apple', 'Motorola']
我需要显示每个对象的正面情绪:
def onButtonPosObject(p):
for key in sentiment_analysis.positiveSentiments.keys():
if key == p:
text.insert(END, sentiment_analysis.positiveSentiments[key])
submenu = Menu(text, tearoff=0)
for p in sentiment_analysis.objects:
submenu.add_command(label=p, command = lambda : onButtonPosObject(p), underline=0)
textmenu.add_cascade(label='Display positive sentiments', menu=submenu, underline=0)
我想我必须要通过标签(p)的值作为onButtonPosObject()函数的参数,我需要从positiveSentiments字典得到一个单词列表,每对象,但我得到像[]的空值。 我会非常感谢任何建议!
这一工程!非常感谢! – 2012-04-24 06:23:54