擅长:python、mysql、java
<p>可以将多行字符串文字与<code>.format</code>一起使用:</p>
<pre><code>sql_statement_format = """
select count(*)
from ept_inv e
where e.ept_type = {device_type}
and e.inv_id = {endpoint_id};
"""
sql_statement = sql_statement_format.format(
device_type=in_row[cs.DeviceType],
endpoint_id=in_row[cs.EndpointId])
</code></pre>
<p>您需要正确地清理SQL查询或<a href="https://www.xkcd.com/327/" rel="nofollow">bad things can happen</a>。有什么理由不使用Python数据库API吗?你知道吗</p>