Python 2.6从缓冲区读取

时间:2013-10-18 20:45:50

标签: python buffer python-2.6 arcpy

Python 2.6 中,如何访问缓冲区?我通过arcpy使用外部python类来访问PostgreSQL数据库函数。

# the_geom is part of a list.
print the_list
# Returns:... 'the_geom': <read-only buffer for 0x06E4FB60, size 1997, offset 0 at 0x34BCCB80>,...

for item in the_list:
    the_geom=item['the_geom']
    print(type(the_geom))
    # Returns: <type 'buffer'>

感谢。

1 个答案:

答案 0 :(得分:1)

buffer可以像其他序列一样进行切片或迭代。

>>> buffer('foobar')
<read-only buffer for 0x7fcdd7caa120, size -1, offset 0 at 0x7fcdd7ca82f0>
>>> buffer('foobar')[3:5]
'ba'
>>> for c in buffer('foobar'):
...   print c
... 
f
o
o
b
a
r