First, create a file object:
f = open("myfile.txt", "w") # Use "a" instead of "w" to append to file
You can print to a file object:
print >> f, '>', alignment.title
print >> f, hsp.sbjct
Or you can write to it:
f.write('> %s
' % (alignment.title,))
f.write('%s
' % (hsp.sbjct,))
You can then close it to be nice:
f.close()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…