我们从Python开源项目中,提取了以下22个代码示例,用于说明如何使用string.joinfields()。
def sendportcmd(s, f, port): hostname = gethostname() hostaddr = gethostbyname(hostname) hbytes = string.splitfields(hostaddr, '.') pbytes = [repr(port//256), repr(port%256)] bytes = hbytes + pbytes cmd = 'PORT ' + string.joinfields(bytes, ',') s.send(cmd + '\r\n') code = getreply(f) # Process an ftp reply and return the 3-digit reply code (as a string). # The reply should be a line of text starting with a 3-digit number. # If the 4th char is '-', it is a multi-line reply and is # terminate by a line starting with the same 3-digit number. # Any text while receiving the reply is echoed to the file. #
def writelines(self, list): self.write(string.joinfields(list, ''))
def flush(self): print 'flush: %d blocks, %d bytes' % (len(self._buffer), self._filled) if self._buffer: import string self._base.writeframes(string.joinfields(self._buffer, '')) self._buffer = [] self._filled = 0
def write_map(self, m): sc = StringCodec() if m is not None: sc.write_uint32(len(m)) sc.write(string.joinfields(map(self._write_map_elem, m.keys(), m.values()), "")) self.write_vbin32(sc.encoded)
def text(self, xy, text): text = string.joinfields(string.splitfields(text, "("), "\\(") text = string.joinfields(string.splitfields(text, ")"), "\\)") xy = xy + (text,) self.fp.write("%d %d M (%s) S\n" % xy)
def __str__(self): """Return a human-readable representation. >>> str(N['dog'][0].synset) '{noun: dog, domestic dog, Canis familiaris}' """ return "{" + self.pos + ": " + string.joinfields(map(lambda sense:sense.form, self.getSenses()), ", ") + "}"
def writelines(self, lines): self.data = self.data + string.joinfields( lines, '\r\n' ) + '\r\n'
def more(self): if not self.file_list: return '' else: # do a few at a time bunch = self.file_list[:50] if self.long: bunch = map(self.longify, bunch) self.file_list = self.file_list[50:] return string.joinfields(bunch, '\r\n') + '\r\n'
def writelines(self, lines): self.write( string.joinfields( lines, '\r\n' ) + '\r\n' )
def hex_digest(s): m = md5() m.update(s) return string.joinfields( map(lambda x: hex(ord(x))[2:], map(None, m.digest())), '', )
def writelines(self, lines): self.data = self.data + string.joinfields( lines, '\r\n' ) + '\r\n' self.check_data()