python - 未检测到 MSO_CONNECT。获取幻灯片上的行数?
问题描述
我需要获取幻灯片上的行数。要访问这些行,我使用的是 MSO_CONNECTOR,因为它不是 AUTO_SHAPE。但是,当我运行以下命令时,由于某种原因,它会返回 None 值。我怎么知道一个形状是不是一条线?(尝试使用 is_connector 也返回错误)
def get_number_of_lines(slide):
lines = 0
for shape in slide.shapes:
if shape.shape_type == MSO_CONNECTOR:
print('it is a line')
lines = lines + 1
return lines
解决方案
嗯,有趣。看起来我们离开.shape_type
了 Connector 对象的属性。我会添加一个问题来解决这个问题。
同时,您可以检查一个独特的Connector
属性,例如.begin_x
:
def is_connector(shape):
"""Return True if `shape` is a connector (line), False otherwise."""
return hasattr(shape, "begin_x")
推荐阅读
- angular - 如何将表单组附加到另一个?
- rx-java2 - RxJava2:将 Completable 转换为 Single - 方法是否等效?
- java - 计算行进距离(不是之间的距离)
- python-3.x - Python3:根据文件内容递归比较两个目录
- python - 如何使用编解码器库将值从烧瓶传递给 html
- mysql - 查找MySql Column中逗号分隔的字符串中是否存在大于数字的值
- python - 是否可以使用 Autograd 计算神经网络输出相对于其输入之一的导数?
- javascript - Twilio 客户端 JS 令牌不允许拨出电话
- sql-server - SQL查询根据条件删除一些项目
- java - Log4J API 不在 Java 程序中打印消息