我试图在代码中查找错误,但是我找不到,此外,我尝试使用以下命令:“sed -i's/\ x0//g'filename”,但未进行任何更改。也许有人可以帮助我。先感谢您!

from pptx import Presentation
from pptx.dml.color import RGBColor



prs = Presentation()
title_slide_layout = prs.slide_layouts[0]
slide = prs.slides.add_slide(title_slide_layout)
title = slide.shapes.title                          # title = prs.slides.add_slide(title_slide_layout).shapes.title
subtitle = slide.placeholders[1]                    # subtitle =  prs.slides.add_slide(title_slide_layout).placeholders[1]
title.text = "Hello, World!"                        # prs.slides.add_slide(title_slide_layout).shapes.title.text = "Hello World!"
subtitle.text = "python-pptx was here!"
title.text_frame.paragraphs[0].font.color.rgb = RGBColor(59,89, 152)
prs.slides.add_slide(title_slide_layout).placeholders[1].text = "python-pptx was here!"


prs.save('test.pptx')´´´

最佳答案

您可以通过将文件声明为utf-8来解决该问题。您所要做的就是将以下行放在文件开头:

# -*- coding: utf-8 -*-

关于python - python-源代码字符串不能包含空字节,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/60681548/

10-09 04:35