我编写了此代码以便在ArcGIS Pro中运行,以在其他单元格之一为true时填充属性表中的某些单元格。当我运行脚本时,表中没有任何反应,也没有收到错误消息。我会忘记执行代码的某些部分吗?谢谢!
import arcpy
fc = 'C://file//path//folder.gdb//featureclass'
fields = ['OBJECT', 'PROJECT', 'LENGTH', 'ID', 'etc.', 'FIELD', 'FIELD2',
'FIELD3', 'FIELD4', 'DV......']
with arcpy.da.UpdateCursor(fc, fields) as rows:
for row in rows:
if(row[10] == "AERIAL"):
row[15] == "N" and row[18] == "AER::"
rows.updateRow(row)
else:
if(row[10] == "BURIED"):
row[15] == "Y" and row[18] == "BUR::"
cursor.updateRow(row)
答案 0 :(得分:0)
您没有在尝试更新行之前为其分配新值。
我认为这是一个语法问题。
这两行:
"root:testing@/mysql?interpolateParams=true"
仅测试package main
import (
"database/sql"
"log"
_ "github.com/go-sql-driver/mysql"
)
type Result struct {
Afield string
Bfield interface{}
}
func main() {
db, err := sql.Open("mysql", "root:testing@/mysql")
if err != nil {
log.Fatal(err)
}
defer db.Close()
if _, err = db.Exec(`CREATE TABLE IF NOT EXISTS mytable(A VARCHAR(50), B INT);`); err != nil {
log.Fatal(err)
}
if _, err = db.Exec(`DELETE FROM mytable`); err != nil {
log.Fatal(err)
}
if _, err = db.Exec(`INSERT INTO mytable(A, B) VALUES ('a', 3)`); err != nil {
log.Fatal(err)
}
var (
usingLiteral Result
usingParam Result
usingLiteralPrepared Result
)
row := db.QueryRow(`SELECT B FROM mytable WHERE A='a'`)
if err := row.Scan(&usingLiteral.Bfield); err != nil {
log.Fatal(err)
}
row = db.QueryRow(`SELECT B FROM mytable WHERE A=?`, "a")
if err := row.Scan(&usingParam.Bfield); err != nil {
log.Fatal(err)
}
stmt, err := db.Prepare(`SELECT B FROM mytable WHERE A='a'`)
if err != nil {
log.Fatal(err)
}
defer stmt.Close()
row = stmt.QueryRow()
if err := row.Scan(&usingLiteralPrepared.Bfield); err != nil {
log.Fatal(err)
}
log.Printf("Type when using literal: %T", usingLiteral.Bfield) // []uint8
log.Printf("Type when using param: %T", usingParam.Bfield) // int64
log.Printf("Type when using prepared: %T", usingLiteralPrepared.Bfield) // int64
}
的值等于row[15] == "N" and row[18] == "AER::"
row[15] == "Y" and row[18] == "BUR::"
或row[15]
,并且"N"
的值等于"Y"
或row[18]
。这些行仅返回"AER::"
或"BUR::"
,行值不会被修改。
如果要为True
和False
分配新值,则必须执行以下代码:
row[15]