我是编程和Python的新手。Python 2.7 - 使用API(HL7)的帮助
我有一个连接到服务器的一个非常基本的python脚本和发送短信:
#!/usr/bin/python
import socket
s = socket.socket()
host = '127.0.0.1'
port = 4106
s.connect((host, port))
message = 'test1'
s.send(message)
print s.recv(1024)
s.close
一切都很好,只是这个消息是HL7消息,需要包裹在MLLP 我发现这API,我觉得能为我做到这一点(http://python-hl7.readthedocs.org/en/latest/api.html#mllp-network-client)
所以我修改我的程序如下,但我不断收到错误消息:NameError:名字“MLLPClient”没有定义
#!/usr/bin/python
import socket
import hl7
host = '127.0.0.1'
port = 4106
with MLLPClient(host, port) as client:
client.send_message('test1')
print s.recv(1024)
s.close
它的工作。谢谢! – atomicluis