[问题]for循环后跟着if判断,但是if部分却没有执行?
#! /usr/bin/pythondna={
'A' : '0',
'C' : '1',
'G' : '2',
'T' : '3'
}
print 'all dna-int pairs are: '
print 'the length of the dic=%d' %len(dna)
for dna, inte in dna.items():
print '%s %s' % (dna, inte)
if 'A' in dna:
print '\n"A" refer to the integer %s in the dict' % dna['A']
多谢各位大牛! 回复 1# 黄河大合唱123
变量名 冲突了. dna 这个变量在 for 里被重新定义了.
OK。多谢啦!回复 2# q1208c
页:
[1]