周期表api。
periodic的Python项目详细描述
安装
>>> pip install periodic
基本用法
将元素作为对象检索
>>> from periodic import element >>> hydrogen = element('hydrogen') >>> hydrogen.mass 1.0079
高级数据库查询(使用sqlalchemy)
>>> from periodic.table import session, Element >>> session.query(Element).order_by(Element.mass).all()[-4:] # 4 heaviest elements (by mass) [<Element('Uup', '115')>, <Element('Uuq', '114')>, <Element('Uuh', '116')>, <Element('Uuo', '118')>]
ascii表
>>> import periodic >>> print periodic.table ----- ----- 1 | H | |He | |---+---- --------------------+---| 2 |Li |Be | | B | C | N | O | F |Ne | |---+---| |---+---+---+---+---+---| 3 |Na |Mg |3B 4B 5B 6B 7B | 8B |1B 2B |Al |Si | P | S |Cl |Ar | |---+---+---------------------------------------+---+---+---+---+---+---| 4 | K |Ca |Sc |Ti | V |Cr |Mn |Fe |Co |Ni |Cu |Zn |Ga |Ge |As |Se |Br |Kr | |---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---| 5 |Rb |Sr | Y |Zr |Nb |Mo |Tc |Ru |Rh |Pd |Ag |Cd |In |Sn |Sb |Te | I |Xe | |---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---| 6 |Cs |Ba |LAN|Hf |Ta | W |Re |Os |Ir |Pt |Au |Hg |Tl |Pb |Bi |Po |At |Rn | |---+---+---+------------------------------------------------------------ 7 |Fr |Ra |ACT| ------------- ------------------------------------------------------------- Lanthanide |La |Ce |Pr |Nd |Pm |Sm |Eu |Gd |Tb |Dy |Ho |Er |Tm |Yb |Lu | |---+---+---+---+---+---+---+---+---+---+---+---+---+---+---| Actinide |Ac |Th |Pa | U |Np |Pu |Am |Cm |Bk |Cf |Es |Fm |Md |No |Lw | -------------------------------------------------------------
交互式shell(控制台脚本)
Periodic提供了一个名为“Periodic”的控制台脚本。
目前仅限于周期表引用。
在未来,它将能够与元素!
这个交互式shell也可以从python解释器调用:
>>> import periodic >>> periodic.interactive_shell()
或从命令行:
$ periodic
Enter any of the following periodic values of the element you are looking for: ['atomic', 'symbol', 'name', 'mass'] Use ^C or type 'exit' to exit. ======================================================================== > 12 atomic: 12 symbol: Mg name: Magnesium mass: 24.305 ======================================================================== > uranium atomic: 92 symbol: U name: Uranium mass: 238.02891 ======================================================================== > H atomic: 1 symbol: H name: Hydrogen mass: 1.00794 ======================================================================== > 15.9994 atomic: 8 symbol: O name: Oxygen mass: 15.9994 ========================================================================