I want to create a string with this exact text: nuke.execute("Write1", 1, 10, 1)
Simply surrounding it with double quotes, like "nuke.execute("Write1", 1, 10, 1)", doesn’t work:
>>> "nuke.execute("Write1", 1, 10, 1)"
File "<stdin>", line 1
"nuke.execute("Write1", 1, 10, 1)"
^
SyntaxError: invalid syntax
>>>
How can I write the string literal in my code?
Simply enclose it in single quotes:
There are several alternatives, such as escaping the embedded quotes with backslashes:
or using triple-quoted strings:
or
You can read more about Python string literals in the manual.