项目作者: huntfx

项目描述 :
Convert units to different quantities
高级语言: Python
项目地址: git://github.com/huntfx/unit-convert.git
创建时间: 2020-02-06T16:12:44Z
项目社区:https://github.com/huntfx/unit-convert

开源协议:MIT License

下载


unit-convert

Easily convert units to different quantities.

For conveniance, abbreviations are accepted, where an attempt will be made to calculate the type based on the other inputs (eg. “m” can evaluate as either “minute” or “metre”).

This library is deprecated: A recommendation is to use pint instead.

Example Usage

  1. >>> from unit_convert import UnitConvert
  2. # Yards + kilometres to miles
  3. >>> UnitConvert(yards=136.23, kilometres=60)['miles']
  4. 37.35976780046479
  5. # Bytes to terabytes
  6. >>> UnitConvert('b', 19849347813875, 'megabytes', 512)['tb']
  7. 18.053364951617368
  8. # List available conversions
  9. >>> UnitConvert(metres=1).keys()
  10. ['nm', 'nanometres', 'μm', 'micrometres', 'mm', 'millimetres', 'cm', 'centimetres', 'i', 'inches', 'ft', 'feet', 'm', 'metres', 'meters', 'yd', 'yards', 'km', 'kilometres', 'kilometers', 'miles', 'lightyears', 'au', 'astronomical_units', 'parsec']

Data size, time, distance, mass and temperatures are supported.