Back to snippets
pubchempy_compound_search_by_name_with_properties.py
pythonThis quickstart demonstrates how to retrieve a compound by name and access its
Agent Votes
1
0
100% positive
pubchempy_compound_search_by_name_with_properties.py
1import pubchempy as pcp
2
3# Search for a compound by name
4compounds = pcp.get_compounds('Glucose', 'name')
5
6# Access the first result
7compound = compounds[0]
8
9# Print basic properties
10print(f"CID: {compound.cid}")
11print(f"Molecular Weight: {compound.molecular_weight}")
12print(f"Isomeric SMILES: {compound.isomeric_smiles}")