使用 python 3.5 执行脚本时出错,但使用 3.8 时运行正常

Eror exucting script with python 3.5 but working fine with 3.8

我 运行 在 Python 3.5 中使用以下脚本 :)

def series_to_fac_details_xml(s):
    return fac_details_xml_template.format(**s)

for index, row in df3.iterrows():
    details = series_to_fac_details_xml(row)
    with open(fr"C:\Users\Max12\Desktop\xml\pdfminer\UiPath\attachments090058\Status\Afgeleverd\{row['Output']}.xml", "w") as f:
        f.write(fac_doc_template.format(fac_details=details))

它给你的错误是“语法无效”.. 然而,使用 python 3.8 它工作得很好。

我必须 运行 Python 3.5 因为 UiPath 只支持 python 版本 >3.6

你能帮忙吗?

问题出在这一行:

with open(fr"C:\Users\Max12\Desktop\xml\pdfminer\UiPath\attachments090058\Status\Afgeleverd\{row['Output']}.xml", "w") as f:

您不能在 python 3.5 中使用 f 弦,因为它们是在 python 3.6 中添加的。使用另一种字符串格式化方法代替 format().