我試圖從__builtins__
無法獲取內建類型
if params.type in ["int", "long", "float"]:
vtype = getattr(__builtins__, params.type)
para = [vtype(para[0])]
得到一個類型,我收到以下錯誤:
Traceback (most recent call last):
File "message_ajax_handler.py", line 267, in get
vtype = getattr(__builtins__, subset[i])
AttributeError: 'dict' object has no attribute 'int'
但是當我測試,在命令行
vtype = getattr(__builtins__, 'int')
它正在工作。我在哪裏犯錯誤。
實際的代碼和回溯中的代碼是不同的。哪一個是正確的? – thefourtheye