当循环中出现异常时,如何跳过循环中的异常继续执行,下面是一种可行的方法:
import pandas as pd
dates=range(20161010,20161114)
pieces=[]
for date in dates:
try:
data=pd.read_csv('A_stock/overview-push-%d/stock overview.csv' %date, encoding='gbk')
pieces.append(data)
except OSError:
pass
continue
data=pd.concat(pieces)
data.shape