I'm using a script to get .fna files from .gbk files
import sys
from Bio import SeqIO
lista = open('list_gbk.txt')
for line in lista:
line = line.rstrip()
fasta = line+".fna"
sys.stdout=open(fasta,"w")
for rec in SeqIO.parse(line, "genbank"):
if rec.features:
for feature in rec.features:
if feature.type == "CDS":
print ">", feature.location, feature.qualifiers['product'],"\n",feature.location.extract(rec).seq
sys.stdout.close()
But I'm getting the next message error
Traceback (most recent call last):
File "parser_gbk_2.py", line 14, in <module>
print ">", feature.location, feature.qualifiers['product'],"\n",feature.location.extract(rec).seq
KeyError: 'product'
Side note: Looks like you're using python2.7 - time to abandon that and switch to python3.6. Python 2.7 will be retired in under 6 months: https://pythonclock.org/