python - 将日期格式从 2019-02-04 更改为 2 月 4 日
问题描述
我有一个用于电子纸框架的 python 脚本。我想将日期从“2019-02-04”改为“04 feb”。我已经调整代码几个小时了,但我无法让它工作。
代码如下所示:
# Calendar strings to be displayed
day_str = time.strftime("%A")
day_number = time.strftime("%d")
month_str = time.strftime("%B") + ' ' + time.strftime("%Y")
month_cal = str(calendar.month(int(time.strftime("%Y")), int(time.strftime("%m"))))
month_cal = month_cal.split("\n",1)[1];
update_moment = time.strftime("%H") + ':' + time.strftime("%M")
解决方案
d = '2019-02-04'
datetime.strptime(d, '%Y-%m-%d').strftime('%d %b')
输出
'04 Feb'
推荐阅读
- ios - 在 XCode 模拟器上使用 Frida
- javascript - onChange react-select 多个选项
- php - 如何验证 Laravel 资源控制器的 show (GET) 方法的输入?
- sql - SQL 查询 - 返回多个详细信息行
- .net - Blazor WASM ASP.NET Core 托管性能
- python - 具有后续匹配值索引的数据框列,包括从最终索引到初始索引的范围环绕方向
- python - ORA-12154: TNS: 无法解析在 python 中指定的连接标识符
- python - python中的滑块
- flutter - 与 Dart 启动配置相关的问题
- html - Angular js 将变量绑定到标签中
我正在尝试将我范围内的值传递到 x 的文本标记中:
<g transform="translate(150,40)"> <rect ng-style="{'width':info}" height="39" fill="#66CC99"></rect> <text x={{info}} y="9.5" dy="1.2em