Python `YYYY-MM-DD`
在Python中,获得的最好方法是什么 RFC 3339 YYYY-MM-DD
来自 gtk.Calendar::get_date()
输出的文本?
In Python, what is the best way to get the
RFC 3339 YYYY-MM-DD
text from the output of gtk.Calendar::get_date()
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
感谢 Mark 和 treeface 提供的解决方案,但似乎我发明了一个更好的解决方案:
这个解决方案更短,更容易理解(在我看来),并且我相信需要更少的处理,因为它消除了元组所在的阶段转换成 UNIX 时间。
Thanks to Mark and treeface for the solutions, but it seems I've invented a better one:
This solution is shorter, easier to understand (in my opinion), and I believe takes less processing as it cuts out the stage where the tuple is converted into UNIX time.
根据 文档, get_date 返回一个 (year,month,day) 元组,其中月份为 0 到 11,日期为 1 到 31,因此:
According to the docs, the get_date returns a tuple of (year,month,day), where month 0 to 11 and day is 1 to 31, so:
这可能对您有用:
http://www.tutorialspoint.com/python/time_strftime.htm
我也刚刚四处寻找这个 gtk get_date 方法,我能够找到一些处理它的代码,如下所示:
所以只需将“%x”替换为“%G-%m-%d”,然后我认为这会起作用。或者至少值得一试。
This might be useful to you:
http://www.tutorialspoint.com/python/time_strftime.htm
I've also just looked around for this gtk get_date method and I was able to find some code that handles it like this:
So just replace "%x" with "%G-%m-%d" and I think it would work. Or at least it's worth a try.