简体   繁体   中英

What is the use of “”“…”“” in python instead of “…” or '…', especially in MySQLdb cursor.execute

is there a difference if i use """..""" in the sql of cusror.execute. Even if there is any slight difference please tell

It's used to split the query over many lines to format it nicely:

db.query("""
    SELECT *
    FROM employee, department 
    WHERE employee.DepartmentID = department.DepartmentID;
""")

Also using """...""" around a string allows you to not escape " and ' inside that string.

不可以,除了字符串可以包含换行符。

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