0
這裏是我的代碼的摘錄:參數沒有得到正確傳遞
def listFrom(here):
print "[DBG] here: " + here
def book(here, there, amount):
print "[DBG] here: " + here + "; there: " + there + "; amount: " + str(amount)
# Code that takes input and stores it into the string input
# Yes, I know this is dangerous, but it's part of a
# school assignment where we HAVE to use eval.
eval(input, {"__builtins__": {}, "listAll": listAll, "listFrom": listFrom, "listFromTo": listFromTo, "book": book, "about": about, "commands": commands, "book": book})
如果我進入listFrom('LON')
,按預期程序返回[DBG] here: LON
。但是,當我做book('LON', 'MAN', 8)
時,我收到了一個莫名其妙的[DBG] here: ☺; there: ☻; amount: ♥
。這可能是什麼原因?
你在哪裏看輸出?你可以發佈IDLE會話嗎?否則無法複製 – SilentGhost 2010-02-27 12:43:28
無法複製。什麼Python和哪個平臺? – 2010-02-27 12:43:50
它似乎對我來說工作正常;你可以發佈你用來獲取用戶輸入的代碼嗎?另外,我會調用字符串變量而不是'input',這是內置函數之一。 您使用的是什麼版本的Python? – tzaman 2010-02-27 12:57:58