按照Python documentation,你必須提供創建選項組時解析器:爲什麼在創建OptionGroup時必須提供解析器兩次?
group = OptionGroup(parser, "Dangerous Options",
"Caution: use these options at your own risk. "
"It is believed that some of them bite.")
然後明確地添加它,你就大功告成了創建OptionGroup
後:
parser.add_option_group(group)
我沒有現在訪問源代碼,但稍後會訪問。也許別人知道。