2013-10-18 105 views
0

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

# 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

buffer s可以被切片或迭代,就像其他序列一样。

>>> 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 
+0

谢谢。我一直在解决这个问题,并且需要一个完整的检查来确认这段代码是正确的!再次感谢。 – Matt