Например, python print() может быть разбит на несколько строк без использования какого-либо явного продолжения строки.
Код: Выделить всё
print(
"{0:s}".format("a"),
"{0:s}".format("b"),
"{0:s}\n".format("c"),
)
Код: Выделить всё
output = open("output.file.txt","w")
output.write(
"{0:s}".format("a"),
"{0:s}".format("b"),
"{0:s}\n".format("c"),
)
Код: Выделить всё
od.write(
~~~~~~~~^
"{0:s}".format("a"),
^^^^^^^^^^^^^^^^^^^^
"{0:s}".format("b"),
^^^^^^^^^^^^^^^^^^^^
"{0:s}\n".format("c"),
^^^^^^^^^^^^^^^^^^^^
)
^
TypeError: TextIOWrapper.write() takes exactly one argument (3 given)
Код: Выделить всё
output = open("output.file.txt","w")
output.write(
"{0:s}".format("a") \
"{0:s}".format("b") \
"{0:s}\n".format("c")
)
Код: Выделить всё
"{0:s}".format("a") \
^^^^^^^^^^^^^^^^^^^^^
SyntaxError: invalid syntax. Perhaps you forgot a comma?
Подробнее здесь: https://stackoverflow.com/questions/798 ... thon-write
Мобильная версия