<p>append语句末尾有一个错误:<code> +';'</code>应该在“append”的括号内。现在,您正在尝试将“append”的结果与字符串(字符)<code>';'</code>连接起来</p>
<p>更正为:</p>
<pre class="lang-py prettyprint-override"><code>sql_texts.append('INSERT INTO '+ ' registry'+' (source, create_time, geo_group_id, status, make, vin, modelId, year)'
+ ' VALUES "MANUAL_LOAD", sysdate, 42, 0, "MITSUBISHI", '+ ',' + str(tuple(row.values)) +';')
</code></pre>
<p>编辑:除了纠正上面的语法错误外,我相信您的代码不会提供您想要的输出,因为您不想将元组添加到字符串中。此语句可能更干净(<a href="https://docs.python.org/3/tutorial/inputoutput.html#the-string-format-method" rel="nofollow noreferrer">using ^{<cd3>} function</a>而不是<code>+</code>)</p>
<pre class="lang-py prettyprint-override"><code>sql_texts.append("INSERT INTO registry (source, create_time, geo_group_id, status, make, vin, modelId, year) VALUES (\"MANUAL_LOAD\", sysdate, 42, 0, \"MITSUBISHI\", \"{0}\", \"{1}\");".format(row.values[1], row.values[2]))
</code></pre>
<p>这将输出为:</p>
<pre><code>['INSERT INTO registry (source, create_time, geo_group_id, status, make, vin, modelId, year) VALUES ("MANUAL_LOAD", sysdate, 42, 0, "MITSUBISHI", "5641", "2021");']
</code></pre>
<p>希望这有帮助</p>