首先,我对Python还不熟悉。我正在使用PTVShttp://pytools.codeplex.com/。接下来我安装了reportlab。然后我在https://github.com/nakagami/reportlab/blob/master/demos/colors/colortest.py#L68运行一个示例演示,但是在第行
all_colors = reportlab.lib.colors.getAllNamedColors().items()
all_colors.sort() # alpha order by name
我得到错误,dict_items object has no attribute sort
只是一个理论:你用的是Python3!
来自https://docs.python.org/3/whatsnew/3.0.html
据我所知,“视图”是一个迭代器,迭代器没有排序函数。把它改成
根据文件
因此,基于Johan的回答,总的解决方案是:
我相信
sort()
方法不再支持Python 3.x。必须将相应的变量传递给
sorted(all_colors)
。相关问题 更多 >
编程相关推荐