我们从Python开源项目中,提取了以下10个代码示例,用于说明如何使用django.utils.six.buffer_types()。
def quote_value(self, value): if isinstance(value, (datetime.date, datetime.time, datetime.datetime)): return "'%s'" % value elif isinstance(value, six.string_types): return "'%s'" % six.text_type(value).replace("\'", "\'\'") elif isinstance(value, six.buffer_types): return "'%s'" % force_text(binascii.hexlify(value)) elif isinstance(value, bool): return "1" if value else "0" else: return str(value)
def to_python(self, value): if isinstance(value, buffer_types): return bytes2int(force_bytes(value)) elif isinstance(value, text_type): return long(value) return value