撸了个年度进度条提示工具 - V2EX
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 6421 次点击
    这是一个创建于 2763 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    安装:
    $ 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
        1
    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
    Gja5kx2zjf92LLin
        18
    Gja5kx2zjf92LLin  
       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     Solana     2564 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 28ms UTC 15:30 PVG 23:30 LAX 08:30 JFK 11:30
    Do have faith in what you're doing.
    ubao snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86