【问题标题】:Eror exucting script with python 3.5 but working fine with 3.8使用 python 3.5 执行脚本时出错,但使用 3.8 可以正常工作
【发布时间】:2021-02-17 17:32:02
【问题描述】:

我在 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\attachments\75090058\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

你能帮忙吗?

【问题讨论】:

  • Python 3.5 还不支持 f 字符串。

标签: python syntax


【解决方案1】:

问题出在这一行:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多