擅长:python、mysql、java
<p>要回答第一部分,您需要<code>getattr</code>:</p>
<blockquote>
<p>Help on built-in function <code>getattr</code> in module <code>__builtin__</code>:</p>
<p><code>getattr(...)</code>
<code>getattr(object, name[, default]) -> value</code></p>
<pre><code>Get a named attribute from an object; getattr(x, 'y') is equivalent to x.y.
When a default argument is given, it is returned when the attribute doesn't
exist; without it, an exception is raised in that case.
</code></pre>
</blockquote>
<p>所以你需要:</p>
<pre><code>syslog.openlog('Blah', 0, getattr(syslog, facility))
</code></pre>
<p>关于你问题的第二部分,关于陈述本身的细目:</p>
<ul>
<li><code>syslog</code>(模块)</li>
<li><code>.</code>(<a href="http://en.wikipedia.org/wiki/Scope_resolution_operator" rel="nofollow">scope resolution operator</a>)</li>
<li><code>openlog</code>(模块的一个属性,在本例中是一个函数)</li>
<li><code>'Blah'</code>(函数的一个参数)</li>
</ul>