gpt4 book ai didi

python - 我如何告诉 python 整个值是一个字符串?因为我的Excel公式中有撇号

转载 作者:行者123 更新时间:2023-12-01 00:22:21 25 4
gpt4 key购买 nike

在Python中

formula = "=sumifs('INVENTORY IN AND OUT'!F:F, 'INVENTORY IN AND OUT'!E:E, "=1",'INVENTORY IN AND OUT'!D:D,"=A",'INVENTORY IN AND OUT'!C:C,"=1") - sumifs('INVENTORY IN AND OUT'!G:G, 'INVENTORY IN AND OUT'!E:E, "=1",'INVENTORY IN AND OUT'!D:D,"=A",'INVENTORY IN AND OUT'!C:C,"=1"

print (formula)

我明白了!!

File "inventory change formula", line 52
formula = "=sumifs('INVENTORY IN AND OUT'!F:F, 'INVENTORY IN AND OUT'!E:E, "=1",'INVENTORY IN AND OUT'!D:D,"=A",'INVENTORY IN AND OUT'!C:C,"=1") - sumifs('INVENTORY IN AND OUT'!G:G, 'INVENTORY IN AND OUT'!E:E, "=1",'INVENTORY IN AND OUT'!D:D,"=A",'INVENTORY IN AND OUT'!C:C,"=1""
^
SyntaxError: invalid syntax

我的问题是如何告诉 python 整个值是一个字符串,因为我的公式中有撇号?

最佳答案

使用转义字符

formula = "=sumifs('INVENTORY IN AND OUT'!F:F, 'INVENTORY IN AND OUT'!E:E, \"=1\",'INVENTORY IN AND OUT'!D:D,\"=A\",'INVENTORY IN AND OUT'!C:C,\"=1\") - sumifs('INVENTORY IN AND OUT'!G:G, 'INVENTORY IN AND OUT'!E:E, \"=1\",'INVENTORY IN AND OUT'!D:D,\"=A\",'INVENTORY IN AND OUT'!C:C,\"=1"

print (formula)

输出

=sumifs('INVENTORY IN AND OUT'!F:F, 'INVENTORY IN AND OUT'!E:E, "=1",'INVENTORY IN AND OUT'!D:D,"=A",'INVENTORY IN AND OUT'!C:C,"=1") - sumifs('INVENTORY IN AND OUT'!G:G, 'INVENTORY IN AND OUT'!E:E, "=1",'INVENTORY IN AND OUT'!D:D,"=A",'INVENTORY IN AND OUT'!C:C,"=1

关于python - 我如何告诉 python 整个值是一个字符串?因为我的Excel公式中有撇号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58871751/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com