如何使用python pptx获取点值以编辑基于它的每个点的格式';s值
如果我运行以下代码如何使用python pptx获取点值以编辑基于它的每个点的格式';s值,python,powerpoint,Python,Powerpoint,如果我运行以下代码 from pptx import Presentation prs = Presentation('test3.pptx') for slide in prs.slides: for shape in slide.shapes: if not shape.has_chart: continue chart = shape.chart for series in chart.series:
from pptx import Presentation
prs = Presentation('test3.pptx')
for slide in prs.slides:
for shape in slide.shapes:
if not shape.has_chart:
continue
chart = shape.chart
for series in chart.series:
print(series.values)
在仅包含图片图表的演示文稿上
我将得到以下输出
(0.1, 0.4, 0.7)
(0.2, 0.5, 0.8)
(0.3, 0.6, 0.9)
因为A、B和C是3个系列
我将如何对图表中的每个点进行类似的操作?以下代码不起作用
from pptx import Presentation
prs = Presentation('test3.pptx')
for slide in prs.slides:
for shape in slide.shapes:
if not shape.has_chart:
continue
chart = shape.chart
for series in chart.series:
for point in series.points:
print(point.values)
我在文档中发现Points不存储值,只存储格式
我的最终目标是能够根据每个点的值分别编辑其格式。e、 g.如果点值>=50%->绿色;如果<50%->颜色为红色等,这是在XML中不同位置找到的两个独立属性,这解释了为什么
点
没有值
属性
但是它们在数量上是一致的,所以把它们放在一起没有问题。内置的zip()
函数仅适用于这种情况:
for point, value in zip(series.points, series.values):
do_whatever_with(point, value)