Python:将时间戳转换为数字或字符串

Python:将时间戳转换为数字或字符串,python,mongodb,timestamp,Python,Mongodb,Timestamp,返回值的打印结果:时间戳(1532221388,1) 问题:我需要创建一个名为“1532221388”而不是“Timestamp(1532221388,1)”的目录 救命啊 谢谢基于pymongo源代码,您可以从time属性time获取实际时间,因此 def GetLastSignificantTS(self,conn): conn=pymongo.MongoClient(uri) db=conn.local return db.oplog.rs.find_one(sor

返回值的打印结果:时间戳(1532221388,1)

问题:我需要创建一个名为“1532221388”而不是“Timestamp(1532221388,1)”的目录

救命啊


谢谢

基于pymongo源代码,您可以从time属性
time
获取实际时间,因此

def GetLastSignificantTS(self,conn):
    conn=pymongo.MongoClient(uri)
    db=conn.local
    return db.oplog.rs.find_one(sort=[('$natural', pymongo.DESCENDING)])['ts'] 
应该有用

db.oplog.rs.find_one(sort=[('$natural', pymongo.DESCENDING)])['ts'].time