try:
代码块
except 异常1:
异常1的解决办法
except 异常2:
异常2的解决办法
except Exception:
剩余的其他异常解决办法
####pybel跳过无法编码SMILES
import pybel
f1 = open('inactive_uni.smi')
f2 = open('inactive1','w')
for i in f1.readlines():
tmp = i.strip().split('\t')
try:
mymol = pybel.readstring('smi', tmp[0])
print (mymol.molwt)
f2.write(i)
except:
print('无法编码')