LoginSignup
2
3

More than 5 years have passed since last update.

めざせpythonライブラリマスター (33)humanfriendly

Posted at

【ライブラリ説明】

 単位や日付の変換、タイマー、ユーザからの入力変換など多くのことが
 分かりやすくコーディングできる。

【プログラム】

humanfriendly.py
# -*- coding: utf-8 -*-

import humanfriendly

user_input = raw_input("Enter a readable file size: ")
# 16KBを入力

num_bytes = humanfriendly.parse_size(user_input)
print num_bytes
# Enter a readable file size: 16384

print "You entered:", humanfriendly.format_size(num_bytes)
# You entered: 16 KB

【参考サイト】

 pypi
 document

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3