字符串str.count(chr)

    1. str1="ACTGATCG"
    2. str1.count("A")

    列表list:用collections.Counter模块

    1. from collections import Counter
    2. import pandas as pd
    3. wordcount = Counter(allwords)
    4. wordcount.most_common(10)
    5. print(wordcount.most_common(10))
    6. df = pd.DataFrame(wordcount.most_common(10),
    7. columns=['word', 'count'])
    8. print(df)

    numpy array

    1. b=a[:,0]
    2. np.sum(b=='x')