Python 为什么我没有得到属性'__获取项目';字典错误?
为什么我没有得到字典的属性Python 为什么我没有得到属性'__获取项目';字典错误?,python,dictionary,optparse,Python,Dictionary,Optparse,为什么我没有得到字典的属性\uuuu getitem\uuu错误: Traceback (most recent call last): File "./thumbnail.py", line 39, in <module> main() File "./thumbnail.py", line 19, in main options['input_pattern'] AttributeError: Values instance has no attribut
\uuuu getitem\uuu
错误:
Traceback (most recent call last):
File "./thumbnail.py", line 39, in <module>
main()
File "./thumbnail.py", line 19, in main
options['input_pattern']
AttributeError: Values instance has no attribute '__getitem__'
选项
不是命令:
print options.input_pattern
如果你必须有口述,使用
options.__dict__
正如另一位用户所说,选项不是字典。我自己犯了这个错误。 如果我有选择的话
--文件文件
然后我可以打电话
option.file
返回文件。就这么简单
options.__dict__