python try  except 异常忽略写法

 

 

inputpath = 'postnew_00000' + str(i) + '_0'
fin = open(inputpath,'r')
reader = codecs.getreader('utf-8')(fin)

foutpth ='./data/'+ 'data_00000' + str(i) + '_0'
fout = open(foutpth, 'w')
writer = codecs.getwriter('utf-8')(fout)

data = reader.readline()
i = 0
while data:
i= i+1
try:
line = data.strip().split('\t')
query = line[0]
idSet = line[1].strip().split(',')
for articleId in idSet:
row = query + '\t' + articleId +'\n'
writer.write(row)
except:
pass
data = reader.readline()

python try  except 异常忽略写法

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-19
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
  • 2021-06-03
猜你喜欢
  • 2021-10-02
  • 2021-12-29
  • 2021-09-08
  • 2022-12-23
  • 2022-12-23
  • 2021-12-29
相关资源
相似解决方案