擅长:python、mysql、java
<p>python3.5中只添加了禁用缩写long选项的功能。从<a href="https://docs.python.org/3/library/argparse.html#argument-abbreviations-prefix-matching" rel="noreferrer">^{<cd1>} documentation</a>:</p>
<blockquote>
<p>The <code>parse_args()</code> method <em>by default</em> allows long options to be abbreviated to a prefix, if the abbreviation is unambiguous (the prefix matches a unique option) ... <strong>This feature can be disabled by setting <em>allow_abbrev</em> to <code>False</code>.</strong></p>
</blockquote>
<p>因此,如果您使用Python3.5,可以使用<code>allow_abbrev=False</code>创建解析器:</p>
<pre><code>parser = argparse.ArgumentParser(..., allow_abbrev=False)
</code></pre>
<p>如果您使用optparse或pre-3.5argparse,那么您只需要使用缩写选项。在</p>