会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132463个问题
Python 全系列/第十三阶段:高并发性能怪兽-Tornado 框架/Tornado项目 12691楼
Python 全系列/第三阶段:Python 网络与并发编程/并发编程 12692楼
Python 全系列/第十五阶段:Python 爬虫开发/移动端爬虫开发- 12693楼
JAVA 全系列/第十一阶段:分布式RPC调用和分布式文件存储/Swagger 12694楼
JAVA 全系列/第十三阶段:分布式文件存储与数据缓存/Nginx 12695楼
Python 全系列/第二十一阶段:Python_数据分析项目(旧)/二手车价格预测 12698楼
Python 全系列/第十阶段:Flask百战电商后台项目/Flask百战电商后台项目 12700楼
WEB前端全系列/第二十阶段:Vue2企业级项目(旧)/疫情动态实时播报 12701楼

老师的源代码运行报错:

from sys import hexversion


def base_use():
    from pptx import Presentation
    from pptx.enum.shapes import MSO_AUTO_SHAPE_TYPE
    from pptx.util import Inches, Pt
    ppt = Presentation()
    slide = ppt.slides.add_slide(ppt.slide_layouts[5])
    shapes = slide.shapes
    shapes.title.text = '流程图'

    top = Inches(3)
    left = Inches(1)
    width = Inches(2)
    height = Inches(1)
    t_sh = shapes.add_shape(MSO_AUTO_SHAPE_TYPE.PENTAGON, left, top, width, height)
    t_sh.text = '第1步'

    for i in range(2, 6):
        left = left + width - Inches(0.4)
        temp = shapes.add_shape(MSO_AUTO_SHAPE_TYPE.CHEVRON, left, top, width, height)
        # temp.text = f'第{i}步'
        p = temp.text_frame
        p.text = f'第{i}步'
        p.fit_text(max_size=10, bold=True, italic=True)

    ppt.save('28_增加流程图.pptx')


if __name__ == "__main__":
    base_use()

错误信息

F:\Python\virtualenv\work_env\Scripts\python.exe F:/Pycharm/14、自动化办公/PPT/test.py
Traceback (most recent call last):
  File "F:\Python\virtualenv\work_env\lib\site-packages\pptx\util.py", line 137, in get_prop_value
    return getattr(obj, cache_attr_name)
AttributeError: '_Font' object has no attribute '__tables'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "F:/Pycharm/14、自动化办公/PPT/test.py", line 32, in <module>
    base_use()
  File "F:/Pycharm/14、自动化办公/PPT/test.py", line 26, in base_use
    p.fit_text(max_size=10, bold=True, italic=True)
  File "F:\Python\virtualenv\work_env\lib\site-packages\pptx\text\text.py", line 88, in fit_text
    font_size = self._best_fit_font_size(
  File "F:\Python\virtualenv\work_env\lib\site-packages\pptx\text\text.py", line 242, in _best_fit_font_size
    font_file = FontFiles.find(family, bold, italic)
  File "F:\Python\virtualenv\work_env\lib\site-packages\pptx\text\fonts.py", line 31, in find
    cls._font_files = cls._installed_fonts()
  File "F:\Python\virtualenv\work_env\lib\site-packages\pptx\text\fonts.py", line 43, in _installed_fonts
    for key, path in cls._iter_font_files_in(d):
  File "F:\Python\virtualenv\work_env\lib\site-packages\pptx\text\fonts.py", line 74, in _iter_font_files_in
    yield ((f.family_name, f.is_bold, f.is_italic), path)
  File "F:\Python\virtualenv\work_env\lib\site-packages\pptx\text\fonts.py", line 155, in family_name
    return self._tables["name"].family_name
  File "F:\Python\virtualenv\work_env\lib\site-packages\pptx\util.py", line 139, in get_prop_value
    value = f(obj)
  File "F:\Python\virtualenv\work_env\lib\site-packages\pptx\text\fonts.py", line 185, in _tables
    return dict(
  File "F:\Python\virtualenv\work_env\lib\site-packages\pptx\text\fonts.py", line 185, in <genexpr>
    return dict(
  File "F:\Python\virtualenv\work_env\lib\site-packages\pptx\text\fonts.py", line 177, in _iter_table_records
    yield tag.decode("utf-8"), off, len_
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x90 in position 2: invalid start byte

Process finished with exit code 1


Python 全系列/ 第十四阶段:自动化操作办公软件、邮件、定时任务等/自动化操作办公软件、邮件、定时任务等 12702楼
Python 全系列/下架-第十二阶段:Python_大型电商项目(5天后下架)/Django项目阶段-电商项目(旧) 12705楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637