本文整理汇总了Python中core.buffer.Buffer.create_from_str方法的典型用法代码示例。如果您正苦于以下问题:Python Buffer.create_from_str方法的具体用法?Python Buffer.create_from_str怎么用?Python Buffer.create_from_str使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.buffer.Buffer
的用法示例。
在下文中一共展示了Buffer.create_from_str方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: connect_handler
# 需要导入模块: from core.buffer import Buffer [as 别名]
# 或者: from core.buffer.Buffer import create_from_str [as 别名]
def connect_handler(socket):
@socket.data_handler
def data_handler(data):
print "Echo client received %s"% data
for i in range(10):
print "Echo client sending %d"% i
socket.write_buffer(Buffer.create_from_str("%d"% i))
示例2: test_create
# 需要导入模块: from core.buffer import Buffer [as 别名]
# 或者: from core.buffer.Buffer import create_from_str [as 别名]
def test_create(self):
buff1 = Buffer.create()
tu.azzert(0 == buff1.length)
buff2 = Buffer.create(100)
tu.azzert(0 == buff1.length)
str = "oqkdioqjwdijqwed"
buff3 = Buffer.create_from_str(str)
tu.azzert(str == buff3.to_string())
tu.test_complete()
示例3: connect_handler
# 需要导入模块: from core.buffer import Buffer [as 别名]
# 或者: from core.buffer.Buffer import create_from_str [as 别名]
def connect_handler(err, socket):
if err is None:
def data_handler(data):
print "Echo client received %s"%data
socket.data_handler(data_handler)
for i in range(10):
print "Echo client sending %d"%i
socket.write(Buffer.create_from_str("%d"% i))
else:
print 'Failed to connect %s' % err
示例4: test_delimited
# 需要导入模块: from core.buffer import Buffer [as 别名]
# 或者: from core.buffer.Buffer import create_from_str [as 别名]
def test_delimited(self):
str = ""
iters = 100
for i in range(0, iters):
str += "line %s"% i
if i != iters - 1:
str += "\n"
self.lines = []
def each_line(line):
self.lines.append(line)
parser = RecordParser.new_delimited("\n", each_line)
parser.input(Buffer.create_from_str(str))
count = 0
for line in self.lines:
tu.azzert("line %i"% count == line.to_string())
count += 1
tu.test_complete()
示例5: each
# 需要导入模块: from core.buffer import Buffer [as 别名]
# 或者: from core.buffer.Buffer import create_from_str [as 别名]
def each(address):
EventBus.send(address, Buffer.create_from_str(sp[2]))