字符串处理不行import datetime
from numba import jit
@jit
def bj():
start = datetime.datetime.now()
file0 = 'ic.csv'
file1 = 'ga.csv'
ic = open(file0)
ga = open(file1)
count_ga = 0
count_ic = 0
for ga_line in ga:
count_ga += 1
ga_str = ga_line.split(',')[1] #获取GA第2列的值
# gaget = ga_line.split(',')[5]
if ga_str == "": #如果GA里的值为空,跳出本次循环不执行下面的for语句
print('GA第 ' +str(count_ga)+' 行为空跳过')
continue
else:
count_ic = 0
ic.seek(0,0)
for ic_line in ic:
count_ic += 1
# print('正在用GA第 ' +str(count_ga)+' 行 与',end = "")
# print('IC第 ' +str(count_ic)+' 行进行匹配')
try:
ic_str = ic_line.split(',')[5] #获取IC第6列的值
if ga_str in ic_str: #如果IC第6列包含GA第2列中的值,则打印出各自的行号,并中断IC读取的循环,进入读取ga的下次循环
# ic.write(ic_line.replace('\n',gaget+'\n')
# print('★★★★GA第%d行与IC第%d行匹配★★★★'%(count_ga,count_ic))
# print(' GA: '+ga_str)
# print(' IC: '+ic_str)
# print('已经将'+gaget+'追加')
break
except IndexError:
print(str(count_ic))
ic.close
ga.close
end = datetime.datetime.now()
print (end-start)
bj()
错误信息:Traceback (most recent call last):
File "d:\刘政\巡查平台开发\百度贴吧爬虫\testcsv.py", line 45, in <module>
bj()
File "C:\ProgramData\Anaconda3\lib\site-packages\numba\dispatcher.py", line 307, in _compile_for_args
return self.compile(tuple(argtypes))
File "C:\ProgramData\Anaconda3\lib\site-packages\numba\dispatcher.py", line 579, in compile
cres = self._compiler.compile(args, return_type)
File "C:\ProgramData\Anaconda3\lib\site-packages\numba\dispatcher.py", line 80, in compile
flags=flags, locals=self.locals)
File "C:\ProgramData\Anaconda3\lib\site-packages\numba\compiler.py", line 766, in compile_extra
return pipeline.compile_extra(func)
File "C:\ProgramData\Anaconda3\lib\site-packages\numba\compiler.py", line 362, in compile_extra
return self._compile_bytecode()
File "C:\ProgramData\Anaconda3\lib\site-packages\numba\compiler.py", line 725, in _compile_bytecode
return self._compile_core()
File "C:\ProgramData\Anaconda3\lib\site-packages\numba\compiler.py", line 712, in _compile_core
res = pm.run(self.status)
File "C:\ProgramData\Anaconda3\lib\site-packages\numba\compiler.py", line 248, in run
raise patched_exception
File "C:\ProgramData\Anaconda3\lib\site-packages\numba\compiler.py", line 240, in run
stage()
File "C:\ProgramData\Anaconda3\lib\site-packages\numba\compiler.py", line 376, in stage_analyze_bytecode
func_ir = translate_stage(self.func_id, self.bc)
File "C:\ProgramData\Anaconda3\lib\site-packages\numba\compiler.py", line 830, in translate_stage
return interp.interpret(bytecode)
File "C:\ProgramData\Anaconda3\lib\site-packages\numba\interpreter.py", line 92, in interpret
self.cfa.run()
File "C:\ProgramData\Anaconda3\lib\site-packages\numba\controlflow.py", line 515, in run
assert not inst.is_jump, inst
AssertionError: Failed at object (analyzing bytecode)
SETUP_EXCEPT(arg=28, lineno=30)
|