简体   繁体   中英

Getting syntax error in Python code step in zap

I'm getting a syntax error and I can't understand why.

I'm writing a simple Zap Code step to set up some values based on input values with a series of if-else statements.

if input_data.['workbench'] == 'True':
    workbench = 'False'
else:
    workbench = 'N.A.'
if input_data.['office'] == 'True':
    office = 'False'
else:
    office = 'N.A.’   # this is the line with the error

When I do a test run of this Python in a Zapier Code step, I get:

Traceback (most recent call last):

SyntaxError: invalid syntax ( <string> , line 8)

I don't expect to get a syntax error at all, and I don't understand why one should occur at line 8 when there is a similar if-else construct prior to that which includes line 8.

There are similar, subsequent constructs before a final return statement (which is a Zapier mechanism).

似乎是一个简单的错字:这行的最后一个字符不是打勾( ' ),而是撇号( ' ):

office = 'N.A.’

You see in the line that caused the error, the comment is highlighted as red (may be different colors in other IDEs), which indicates it is recognized as part of a string. Hence the error is cause by the string literal not closing appropriately, because of the typo of ' .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM