How to implement multiline string by python
This article mainly introduces python how to achieve multi-line string, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
Multiline string
The basic way is to use a backslash derived from C:
MultiStr= "select * from multi_rowwhere row_id < 5" print (multiStr) # select * from multi_rowwhere row_id < 5
Another technique is to use three quotation marks:
MultiStr= "" select * from multi_rowwhere row_id < 5 "" print (multiStr) # select * from multi_row#where row_id < 5 "
The common problem with the above methods is the lack of appropriate indentation, which will insert spaces in the string if we try to indent. So the final solution is to split the string into multiple lines and enclose the entire string in parentheses:
MultiStr= ("select * from multi_row"where row_id < 5"order by age") print (multiStr) # select * from multi_row where row_id < 5 order by age Thank you for reading this article carefully. I hope the article "how to implement multi-line strings in python" shared by the editor will be helpful to you. At the same time, I also hope you will support us, pay attention to the industry information channel, and more related knowledge is waiting for you to learn!