#!/usr/bin/python3
from rdkit import Chem
from rdkit.Chem import Draw
spl = Chem.SDMolSupplier('molecules.sdf') #读入分子库
mols = []
for mol in spl:
mols.append(mol)
# 获取前十个分子
mols = mols[:10]
#输出分子结构
img = Draw.MolsToGridImage(mols, molsPerRow=5,subImgSize=(300, 300))
img.save("molecules1.png")
![](https://i-blog.csdnimg.cn/blog_migrate/7209187f10d43b21e3a930227be01ebf.jpeg)