【问题标题】:Python 2.6 read from bufferPython 2.6 从缓冲区读取
【发布时间】:2013-10-18 20:45:50
【问题描述】:

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'>

谢谢。

【问题讨论】:

    标签: python buffer python-2.6 arcpy


    【解决方案1】:

    buffers 可以像其他序列一样被切片或迭代。

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

    【讨论】:

    • 谢谢。我一直在解决几个问题,需要进行健全性检查以确认我的这部分代码是正确的!再次感谢。
    猜你喜欢
    • 2012-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多