0
我正在使用一個API,需要我給出3個參數。Python - 發送參數作爲結構
string sessionKey
int serverId
struct date details
dateTime.iso8601 startDate - Optional, unless endDate is provided.
dateTime.iso8601 endDate - Optional.
我不知道如何在這種情況下定義一個結構。我以這種方式調用API。
>>> server.system.provisioning.snapshot.listSnapshots(sessionKey,1000078204, {datetime.now() , datetime.now()})
這樣的IM定義我struct
的語法:
{datetime.now() , datetime.now()}
這給了我一個錯誤:
Traceback (most recent call last):
File "/usr/lib64/python3.4/xmlrpc/client.py", line 512, in __dump
f = self.dispatch[type(value)]
KeyError: <class 'set'>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python3.4/xmlrpc/client.py", line 1098, in __call__
return self.__send(self.__name, args)
File "/usr/lib64/python3.4/xmlrpc/client.py", line 1431, in __request
allow_none=self.__allow_none).encode(self.__encoding)
File "/usr/lib64/python3.4/xmlrpc/client.py", line 951, in dumps
data = m.dumps(params)
File "/usr/lib64/python3.4/xmlrpc/client.py", line 504, in dumps
dump(v, write)
File "/usr/lib64/python3.4/xmlrpc/client.py", line 516, in __dump
raise TypeError("cannot marshal %s objects" % type(value))
TypeError: cannot marshal <class 'set'> objects
難道我定義struct
錯了嗎?
這個問題沒有什麼關係[標籤:C] –