Mar*_*ter -1 python format time datetime python-3.x
我正在使用 API,该 API 需要以下数据格式:
Wed Jan 07 2015 18:58:40
Run Code Online (Sandbox Code Playgroud)
datetime如何使用和模块将现在的时间转换为这种数据格式time?
print(datetime.now().strftime(\'%a %b %d %Y %H:%M:%S\'))\nRun Code Online (Sandbox Code Playgroud)\n\n会显示类似以下内容:
\n\nprint(datetime.now().strftime(\'%a %b %d %Y %H:%M:%S\'))\nRun Code Online (Sandbox Code Playgroud)\n\n使用的格式选项如下:
\n\n%a工作日作为 locale\xe2\x80\x99s 缩写名称。%b月份为 locale\xe2\x80\x99s 缩写名称。%d以零填充的十进制数表示的月份中的某一天。%Y以十进制数表示的年份和世纪。%H小时(24 小时制),以零填充的十进制数。%M分钟作为补零十进制数。%S第二个是补零的十进制数。然后要将其转换为发送格式,您可能需要进行调查quote_plus(),例如:
from datetime import datetime\nimport urllib\n\nnow = datetime.now().strftime(\'%a %b %d %Y %H:%M:%S\')\nprint(urllib.parse.quote_plus(now))\nRun Code Online (Sandbox Code Playgroud)\n\n这会给你:
\n\nThu Mar 24 2016 10:09:18\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
1971 次 |
| 最近记录: |