gpt4 book ai didi

python - 脚本正在跳过功能

转载 作者:太空宇宙 更新时间:2023-11-04 13:00:11 25 4
gpt4 key购买 nike

我不知道这段代码发生了什么,出于某种原因,它似乎完全跳过了这个函数。

    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

最佳答案

我想通了,一些天才只用一个变量声明创建了函数 crcDrvr 两次,所以它一定是命中了那个 – 吉姆

关于python - 脚本正在跳过功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34158914/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com