Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/352.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 未检测到MSO_连接。获取幻灯片上的行数?_Python_Powerpoint_Python Pptx - Fatal编程技术网

Python 未检测到MSO_连接。获取幻灯片上的行数?

Python 未检测到MSO_连接。获取幻灯片上的行数?,python,powerpoint,python-pptx,Python,Powerpoint,Python Pptx,我需要得到幻灯片上的行数。为了访问线路,我使用MSO_连接器,因为它不是自动形状。但是,当我运行下面的函数时,由于某种原因,它返回一个None值。我怎么知道一个形状是不是一条线?尝试使用is_连接器时也返回了一个错误 def get_number_of_lines(slide): lines = 0 for shape in slide.shapes: if shape.shape_type == MSO_CONNECTOR: print('

我需要得到幻灯片上的行数。为了访问线路,我使用MSO_连接器,因为它不是自动形状。但是,当我运行下面的函数时,由于某种原因,它返回一个None值。我怎么知道一个形状是不是一条线?尝试使用is_连接器时也返回了一个错误

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

看起来应该使用MSO_连接器的属性进行比较。 前


嗯,很有趣。看起来我们将.shape_type属性从连接器对象中移除了。我将添加一个问题来解决这个问题

同时,您可以检查独特的连接器属性,如.begin\u x:


同样的问题。。它没有抓住它。。。我在ppt中手动添加行并保存文件,然后运行上面的代码(包括您的代码),但它不会捕获任何行。。Thanksma可能需要迭代连接器?
if shape.shape_type == MSO_CONNECTOR.STRAIGHT:
def is_connector(shape):
    """Return True if `shape` is a connector (line), False otherwise."""
    return hasattr(shape, "begin_x")