为什么 from reportlab.graphics.shapes 导入字符串不起作用

Why isn't from reportlab.graphics.shapes import string working

Python 3.4 报告实验室 3.2.0

from reportlab.graphics.shapes import string

以前工作过。升级到较新的 Python 和 reportlab,但它不再有效。

它是被替换、淘汰还是移动?

基于 bitbucket 上的 source,问题很简单,您应该将 string 大写,这样您的导入如下:

from reportlab.graphics.shapes import String

根据 PEP 0008 -- Style Guide for Python Code

始终应该采用的方式

Class Names

Class names should normally use the CapWords convention.

The naming convention for functions may be used instead in cases where the interface is documented and used primarily as a callable.

Note that there is a separate convention for builtin names: most builtin names are single words (or two words run together), with the CapWords convention used only for exception names and builtin constants.