Skip to main content

What is unitconv?

A units converter that understands a lot of written queries and produce a nice human response:

>>> import unitconv
>>> unitconv.convert("3 meters in cm")
'3 meters = 300 centimeters'

>>> unitconv.convert("1000 grams in kg")
'1000 grams = 1 kilogram'

>>> unitconv.convert("2 cups to l")
'2 US cups = 0.4732 litres'

>>> print unitconv.convert("300 yards")
300 yards = 274.32 meters

>>> unitconv.convert("34 days in weeks")
'34 days = 4.8571 weeks'

>>> unitconv.convert("45mg in ounces")
'45 milligrams = 0.0016 ounces'

>>> print unitconv.convert("300K in °f")
300K = 80.33°F

>>> unitconv.convert("50 cubic feet in m3")
'50 cubic feet = 1.4158 cubic meters'

>>> unitconv.convert("2 cups in l")
'2 US cups = 0.4732 litres'

>>> unitconv.convert("4 teaspoons")
'4 US teaspoons = 19.7157 millilitres'

You can also use it as a script:

$ unitconv 42 km to miles
42 kilometers = 26.0976 miles

Project’s history

Code here comes from other internal Canonical’s project, this part was opensourced in 2018:

https://launchpad.net/unitconv

I forked that to bring it to GitHub, migrate it to Python 3, shape it more like a project (have a setup.py, etc.), and do some releases.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

unitconv-1.tar.gz (11.9 kB view details)

Uploaded Source

File details

Details for the file unitconv-1.tar.gz.

File metadata

  • Download URL: unitconv-1.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.9

File hashes

Hashes for unitconv-1.tar.gz
Algorithm Hash digest
SHA256 d09e8db3826556007d24daffd0dff35830a457c0f390ba7a844ca6ed95e35d99
MD5 90947a0d0f08c9d91d054adb59c98bef
BLAKE2b-256 5d639cc9b213077bfca4a0e3d0ab5dbda5746cffbfffe2627617550f742e15bd

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1 This release

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page