我想在python环境中将日期时间字符串数组(YYYY-MM-DD hh:MM:ss)转换为GPS秒(2000-01-01 12:00:00之后的秒)
为了在LinuxBash中获取单个日期的GPS秒数,我只需输入date2sec datetimestring
,它就会返回一个数字
我可以在python中的for循环中实现这一点。但是,由于它是一个外部脚本,我如何将其合并到python脚本中呢
或者,是否有其他方法可以将日期时间字符串数组(或合并到for循环中的单个日期时间字符串)转换为GPS时间而不使用date2sec
Tags:
以下是我在for循环中用于整个日期时间数组的解决方案:
一个日期时间条目的简单转换为:
不需要导入
datetime
更新答案:使用Astropy库:
在这里,您以UTC设置日期,并且
t.gps
将日期时间转换为GPS秒进一步的研究表明,直接使用datetime对象不会考虑闰秒。
其他有用的链接如下: How to get current date and time from GPS unsegment time in python
相关问题 更多 >
编程相关推荐