Row

摘要

The Row object represents the row of a table. The Row object is returned from InsertCursor, SearchCursor, and UpdateCursor.

讨论

The Row object dynamically support field names from the data source as read/write properties. Field names that can be support directly as a property, such as qualified field names that include periods, can be accessed using the setValue and getValue methods.

方法概述

方法说明
getValue (field_name)

Gets the field value.

isNull (field_name)

Is the field value null.

setNull (field_name)

Sets the field value to null.

setValue (field_name, object)

Sets the field value.

方法

getValue (field_name)
参数说明数据类型
field_name

The field from which the value will be accessed.

String
返回值
数据类型说明
Object

The field value.

isNull (field_name)
参数说明数据类型
field_name

The field to be queried.

None
返回值
数据类型说明
Boolean

True if the field value is null.

setNull (field_name)
参数说明数据类型
field_name

The field that will be set to null.

String
setValue (field_name, object)
参数说明数据类型
field_name

The field that will be set to the new value.

String
object

The value used to set the field value.

Object

代码示例

Row example

Use update cursor to fetch row from feature class, update field value and row, iterating through rows in cursor.

import arcpy
from arcpy import env
import string

# Set the workspace
#
env.workspace = "C:/Data"

# Use row object to get and set field values
# 
cur = arcpy.UpdateCursor("Addresses.dbf", '"STATENAME" = \'Ariz\'' )

# Iterate through rows and update values
#
for row in cur:
    row.STATENAME = string.replace(row.STATENAME, "Ariz", "Arizona")
    cur.updateRow(row)

del cur, row

相关主题


7/10/2012