例题2.2

DENWOSHUABAZONGSHI / 2024-11-10 / 原文

例题2.1代码

import numpy as np
a = []
with open('F:\python数学建模与算法\第二章例题\data2_2.txt') as f:
    for (i, s) in enumerate(f):
        a.append([s.count('a'), s.count('c'), s.count('g'),s.count('t')])
b = np.array(a); print(b)