我不知道这段代码是怎么回事,因为某些原因它似乎完全跳过了这个函数。
try:
readHandle = open(fileName, 'r')
except IOError, ioe:
print "Cannot open file: ", fileName,"\n"
print "%s" %ioe
raise
lines = readHandle.readlines()
lineNum = 1
#read file line by line
for line in lines:
if line.startswith(':'):
#remove : from line
bits0 = line.partition(':')
#remove \n newlines
bits1 = bits0[2].partition('\n')
#split in to an array using , as delimiter
bits2 = bits1[0].split(',')
DrvrNum = bits2[0]
DrvrNam = bits2[1]
# Debug
if DBUG == 1:
print "DrvrNum and DrvrNam variable values"
print DrvrNum, DrvrNam
crcDrvr(DrvrNum, DrvrNam)
elif line.startswith('#'):
#Comment line
pass
elif line.startswith('Ss'):
#Crc line
pass
elif line.startswith('Zz'):
#end of file
pass
else:
print '\nError: line', lineNum , 'is an illegal entry'
print '\nPlease Check'
sys,exit(0)
lineNum = lineNum + 1
这是被跳过的功能:
def crcDrvr(number,name):
convNum = int(number,16)
convNam = ''
for char in name:
hexChar = char.encode("hex")
print hexChar
任何人都可以告诉我哪里出错导致我的代码跳过?
示例数据:
#DrvrDB
#
#
#
Ss1234
:744,Bob Hope
:747,Testy Tester
:777,Extra Guy
:0,dummy
Zz
#Driver#,DriverName
#end of file padding 1
答案 0 :(得分:0)
我想通了,有些天才只用变量声明创建了两次函数crcDrvr
所以它一定是打了一个
- 吉姆