我在导入matlab.engine之后在jupyter笔记本中运行了一个Matlab脚本:
import requests
import xml.etree.ElementTree as et
def xml_event_info(eventID):
xml ='''
<?xml version="1.0" encoding="UTF-8"?>
<YourMembership>
<Version>2.25</Version>
<ApiKey>xxx-xxx</ApiKey>
<CallID>001</CallID>
<></>
<SaPasscode>xxxx</SaPasscode>
<Call Method = "Sa.Events.Event.Get">
<EventID>{}</EventID>
</Call>
</YourMembership>
'''
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
r = requests.post('https://api.yourmembership.com',
data=xml.format(eventID), headers=headers)
print(r.text)
xml ='''
<?xml version="1.0" encoding="UTF-8"?>
<YourMembership>
<Version>2.25</Version>
<ApiKey>xxxxx</ApiKey>
<CallID>008</CallID>
<></>
<SaPasscode>xxxx</SaPasscode>
<Call Method = "Sa.Events.All.GetIDs">
<StartDate>2017/01/1</StartDate>
<EndDate>2017/12/31</EndDate>
</Call>
</YourMembership>
'''
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
r = requests.post('https://api.yourmembership.com', data=xml, headers=headers)
# BUILD XML TREE OBJECT
dom = et.fromstring(r.text)
# PARSE EVENT ID TEXT AND PASS INTO FUNCTION
for i in dom.iterfind('.//EventID'):
xml_event_info(i.text)
但它显示错误:
for i = 1 : size(my_arr,1)
...
end
- 后来我发现内核被设置为python。
我确实安装了matlab内核并导入了matlab.engine,但matlab内核并未显示为Jupyter kerenls下的选项之一。
细节:
for i = 1 : size(my_arr,1)
^
SyntaxError: invalid syntax