擅长:python、mysql、java
<p>我根据<a href="http://www.python.org/dev/peps/pep-0008/" rel="nofollow">the python style guide</a>重新格式化了代码,并添加了一些优化:</p>
<pre><code>table = u'''A,This is A
B,This is B
C,This is C
D,This is D
E,This is E
F,This is F
G,This is G
H,This is H
I,This is I
J,This is J'''
search_value = u'''A
B
C
D
Bang
F
Bang
G
H'''
line_text = dict(line.split(",") for line in table.splitlines())
for target_value in search_value.splitlines():
print line_text.get(target_value, "Error: {0}".format(target_value))
</code></pre>