擅长:python、mysql、java
<p>包括“\t”不存在时的情况</p>
<pre><code>from collections import Counter
myInputList = ['Hauses\tNN\tHaus', 'guten\tADJ\tgut', 'geht\tVFIN\tgehen','xyz']
Counter([x.split('\t')[1] for x in myInputList if '\t' in x])
</code></pre>
<p>转换成字典</p>
<pre><code>from collections import Counter
myInputList = ['Hauses\tNN\tHaus', 'guten\tADJ\tgut', 'geht\tVFIN\tgehen','xyz']
d=dict(Counter([x.split('\t')[1] for x in myInputList if '\t' in x]))
print(d['NN'])
</code></pre>
<p><strong>输出:1</strong></p>