擅长:python、mysql、java
<p>您让Python创建一个包含字符串的元组:</p>
<pre><code>ticketJson['sentTo'] = sentTo,
# ^
</code></pre>
<p>它是定义元组的逗号。括号仅用于消除元组与逗号的其他用法之间的歧义,例如在函数调用中。你知道吗</p>
<p>从<a href="https://docs.python.org/2/reference/expressions.html#parenthesized-forms" rel="noreferrer"><em>Parenthesized forms</em> section</a>:</p>
<blockquote>
<p>Note that tuples are not formed by the parentheses, but rather by use of the comma operator. The exception is the empty tuple, for which parentheses <em>are</em> required — allowing unparenthesized “nothing” in expressions would cause ambiguities and allow common typos to pass uncaught.</p>
</blockquote>
<p>从<a href="https://docs.python.org/2/reference/expressions.html#expression-lists" rel="noreferrer"><em>Expression lists</em></a>开始:</p>
<blockquote>
<p>An expression list containing at least one comma yields a tuple. The length of the tuple is the number of expressions in the list. The expressions are evaluated from left to right.</p>
</blockquote>