V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
0xABCD
V2EX  ›  Python

撸了个年度进度条提示工具

  •  
  •   0xABCD · 2018-03-21 00:31:04 +08:00 · 5762 次点击
    这是一个创建于 2200 天前的主题,其中的信息可能已经有所发展或是发生改变。

    人生苦短,要时刻提醒自己时间在流逝。

    安装:
    $ pip install datebar

    使用:
    $ datebar
    passed days: 79
    the progress of the year: 22%
    ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░22%

    Github:
    https://github.com/Neulana/datebar

    喜欢自取,能赏个 star 就更好啦!比心

    24 条回复    2018-03-21 13:36:14 +08:00
    Williamwang
        1
    Williamwang  
       2018-03-21 07:14:44 +08:00 via iPhone
    手机下载即刻 app,关注对应主题,并开启推送就搞定了……
    TimCheng
        2
    TimCheng  
       2018-03-21 07:29:59 +08:00 via iPhone
    等着接我的 star 吧
    0xABCD
        3
    0xABCD  
    OP
       2018-03-21 08:27:25 +08:00 via Android
    @Williamwang 回头下一个试试
    0xABCD
        4
    0xABCD  
    OP
       2018-03-21 08:27:44 +08:00 via Android
    gimp
        5
    gimp  
       2018-03-21 08:37:36 +08:00   ❤️ 1
    gihnius
        6
    gihnius  
       2018-03-21 08:42:53 +08:00
    写个 Ruby 的玩玩:
    percent = ((Time.now.yday.to_f / Time.now.at_end_of_year.yday) * 100).round
    bar = '▓' * percent + '░' * (100 - percent)
    puts "Progress of this year:"
    puts(bar + percent.to_s + '%')

    输出:
    Progress of this year:
    ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░22%
    anson2416
        7
    anson2416  
       2018-03-21 09:00:20 +08:00 via iPhone
    excel 能做吗
    326029212
        8
    326029212  
       2018-03-21 09:03:01 +08:00
    测试对 python2 稍有不兼容.随手提了个合并
    ZeroW
        9
    ZeroW  
       2018-03-21 09:21:13 +08:00 via Android
    @Williamwang 什么意思,好像不太明白~
    jasonyang9
        10
    jasonyang9  
       2018-03-21 09:29:35 +08:00
    坐等 PHP 版
    gihnius
        11
    gihnius  
       2018-03-21 09:31:20 +08:00
    再写个 Go 的:
    package main

    import (
    "fmt"
    "math"
    "strings"
    "time"
    )

    func main() {
    now := time.Now()
    passed := now.YearDay()
    format := "2006-01-02 15:04:05"
    end, _ := time.Parse(format, fmt.Sprintf("%d-12-31 23:59:59", now.Year()))
    total := end.YearDay()
    progress := math.Round((float64(passed) / float64(total)) * 100)
    bar := strings.Repeat("▓", int(progress)) + strings.Repeat("░", (100-int(progress)))
    fmt.Printf("Progress of this year %d of %d:\n", passed, total)
    fmt.Println(bar)
    }

    感觉够折腾的。。。。。
    clino
        12
    clino  
       2018-03-21 09:32:38 +08:00
    0xABCD
        13
    0xABCD  
    OP
       2018-03-21 09:49:02 +08:00 via Android
    @gihnius 感觉 Ruby 跟 Python 真的很像啊
    0xABCD
        14
    0xABCD  
    OP
       2018-03-21 09:53:12 +08:00 via Android
    @326029212 多谢了
    0vels
        15
    0vels  
       2018-03-21 10:09:00 +08:00
    之前做过一个农历版的,代码太烂,不好意思贴地址了
    0xABCD
        16
    0xABCD  
    OP
       2018-03-21 10:09:26 +08:00 via Android
    @gihnius 为你的折腾精神点赞👍
    lrxiao
        17
    lrxiao  
       2018-03-21 10:23:10 +08:00
    kaminono
        18
    kaminono  
       2018-03-21 10:27:51 +08:00
    可以 fork 吗?
    0xABCD
        19
    0xABCD  
    OP
       2018-03-21 10:31:44 +08:00 via Android
    @lixycoderfix 当然
    Williamwang
        20
    Williamwang  
       2018-03-21 11:44:17 +08:00 via iPhone
    @zerowang317 #9 即刻 app 有对应的提醒主题
    gihnius
        21
    gihnius  
       2018-03-21 11:51:22 +08:00
    @0xABCD Go 版运行快很多。。。
    gihnius
        22
    gihnius  
       2018-03-21 12:50:52 +08:00
    gihnius
        23
    gihnius  
       2018-03-21 13:24:30 +08:00
    @gihnius 继续玩:

    Go 版加了:

    ■■■■■■■■■■■■■■■■■■■■■
    ■■■■■■■■■■■■■■■■■■■■■
    ■■■■■■■■■■■■■■■■■■■■■
    ■■■■■■■■■■■■■■■■■□□□□
    □□□□□□□□□□□□□□□□□□□□□
    □□□□□□□□□□□□□□□□□□□□□
    □□□□□□□□□□□□□□□□□□□□□
    □□□□□□□□□□□□□□□□□□□□□
    □□□□□□□□□□□□□□□□□□□□□
    □□□□□□□□□□□□□□□□□□□□□
    □□□□□□□□□□□□□□□□□□□□□
    □□□□□□□□□□□□□□□□□□□□□
    □□□□□□□□□□□□□□□□□□□□□
    □□□□□□□□□□□□□□□□□□□□□
    □□□□□□□□□□□□□□□□□□□□□
    □□□□□□□□□□□□□□□□□□□□□
    □□□□□□□□□□□□□□□□□□□□□
    □□□□□□□□ 22%(80/365)
    scriptB0y
        24
    scriptB0y  
       2018-03-21 13:36:14 +08:00
    今年还要工作多少天 Twitter 机器人:

    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2635 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 15:32 · PVG 23:32 · LAX 08:32 · JFK 11:32
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.