Code Monkey home page Code Monkey logo

Comments (4)

EillesWan avatar EillesWan commented on September 24, 2024

主要是,日期有三个数用以辨认,如果单纯地写成 {zh_obj:>xx} 这样的形式,其实反而会出误解,比如如果写{zh_obj:>6} 是大于六月的日期还是大于六号的日期?我们还是需要保证代码可读性的吧……

from zhdate.

t3190687 avatar t3190687 commented on September 24, 2024

新年快乐;感谢回应 @EillesWan
我的意思是, {str:>16} 是向右对齐16字符的意思,不是大于还是小于16号
我发现这个可能是python对于unicode的特色;如果我把 str 返回的字串再拿去format() 一次,结果就可以向右对齐。
可能就是这个nested 结构看了复杂,但是可以用就是了。感谢。

 python3 -c 'from zhdate import ZhDate; d1=ZhDate(2024,1,1); s1=("{}".format(d1)); print("{:>16}".format(s1))'
     农历2024年1月1日
# or 
python3 -c 'from zhdate import ZhDate; d1=ZhDate(2024,1,1);  print("{:>16}".format("{}".format(d1)))'
     农历2024年1月1日

from zhdate.

t3190687 avatar t3190687 commented on September 24, 2024

使用者自己可以藉由巢状结构,即, "{:>16}.format( "{}".format(zh_obj)) ,来避开 {:>16} 向右对齐失败的问题。
感谢

from zhdate.

EillesWan avatar EillesWan commented on September 24, 2024

啊,非常抱歉,我确实理解错了你的意思(完了暴露自己没水平了😅),这确实是一个蛮有用的提议,可以试试加上

from zhdate.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.