我正在尝试使用python将matlab文件中的序列日期数字数据转换为UTC。
from datetime import *
import scipy.io as sio
import toutc as toutc
from numpy import *
from plotting import *
import matplotlib.pyplot as plt
S = sio.loadmat(*MatLab_File.mat*)
print (S.keys()) # Time is stored as the key 't'
from datetime import datetime, timedelta
SDN = S[str(input('time'))] # Establishing we are using the key 't'
X = (datetime.fromordinal(SDN) + timedelta(days=SDN%1) - timedelta(days = 366))
最后一行返回
Traceback (most recent call last):
File "matgraph.py", line 19, in <module>
X = (datetime.fromordinal(SDN) + timedelta(days=SDN%1) - timedelta(days = >366))
TypeError: only length-1 arrays can be converted to Python scalars
知道为什么这行不通吗?
谢谢
编辑:在最后一行将'[]'更改为'()',并更新了错误以匹配
您有fromordinal[SDN]
而不是fromordinal(SDN)
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句