在python 2.7中有total_seconds()方法.
在python 2.6中,它不存在,它建议使用
(td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6
Run Code Online (Sandbox Code Playgroud)
有人可以告诉我如何在下面实现它吗?
谢谢
import datetime
timestamp = '2014-10-24 00:00:00'
timestamp = int((datetime.datetime.strptime(timestamp, '%Y-%m-%d %H:%M:%S') - datetime.datetime(1970,1,1)).total_seconds())
print timestamp
timestamp = '2014-10-24 00:00:00'
timestamp = datetime.datetime.strptime(timestamp, '%Y-%m-%d %H:%M:%S') - datetime.datetime(1970,1,1)
print timestamp
Run Code Online (Sandbox Code Playgroud) 我有output.txt一个Bitnami实例上调用的文件.我正在尝试使用scp本地终端窗口上的命令将其复制到本地计算机.但它不会复制.我究竟做错了什么?
scp -i /home/tom/Downloads/zoodigital.pem bitnami@52.191.41.160:/home/bitnami/output.txt
输出:
usage: scp [-12346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
[-l limit] [-o ssh_option] [-P port] [-S program]
[[user@]host1:]file1 ... [[user@]host2:]file2
谢谢
python 2.6不支持timedelta.total_seconds().下面的代码适用于python 2.7.有谁知道如何转换为2.6中的等效?
谢谢
import datetime
timestamp = 1414270449
timestamp = int((datetime.datetime.strptime(timestamp, '%Y-%m-%d %H:%M:%S') - datetime.datetime(1970,1,1)).total_seconds())
Run Code Online (Sandbox Code Playgroud)
抱歉,
我在下面有相同的代码.如何在python 2.6中使用实现total_seconds()
(td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6`
import datetime
timestamp = '2014-10-24 00:00:00'
timestamp = int((datetime.datetime.strptime(timestamp, '%Y-%m-%d %H:%M:%S') - datetime.datetime(1970,1,1)).total_seconds())
print timestamp
timestamp = '2014-10-24 00:00:00'
timestamp = datetime.datetime.strptime(timestamp, '%Y-%m-%d %H:%M:%S') - datetime.datetime(1970,1,1)
print timestamp
Run Code Online (Sandbox Code Playgroud)
谢谢