java - 在python中以毫秒为单位获取GMT时间
问题描述
试图在 Python 中以毫秒为单位获得 GMT,我可以在 Java 中实现它,但需要 python 帮助。爪哇版:
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
long time = cal.getTimeInMillis();
Sample output - 1528893731677
蟒蛇版本:
millis = int(round(time.time() * 1000)) // How to get GMT time here?
Sample output - 1528953926983
解决方案
from datetime import datetime
print(datetime.utcnow().timestamp() * 1000)
推荐阅读
- c++ - 会员运营商和doxygen难度
- java - 移动后保留数据
- python - 使用 python 脚本(数据库 URI)连接到 postgresql,但将“conn”检测为字符串
- spss - 为相同的变量值添加相同的数据(即 ID)
- sql - 从 TSQL 中的表列表中检查表是否为空
- python - 如何使用循环数进行计算但不计算python
- amazon-web-services - 将 Cognito Authorizer 添加到 CDK 中的 Api Gateway LambdaRestAPI
- django - Django过滤没有ManyToManyField“通过”关系的多对多关系
- android - 如何编写单元测试用例 Volley API?
- r - 将 R 中不太常见的因子级别合并到“其他”中