输出每个字段的名称,类型和长度

import arcpy
... from arcpy import env
... env.workspace = "I:\pystudy\shili"
... fieldlist = arcpy.ListFields("fydltb.shp")
... for field44 in fielist:
...     print "{0} is a type of {1} with a lengh of {2}" .format(field44.name,field44.type,field44.length)
...     
FID is a type of OID with a lengh of 4
Shape is a type of Geometry with a lengh of 0
BSM is a type of Integer with a lengh of 9
YSDM is a type of String with a lengh of 10
TBYBH is a type of String with a lengh of 8
TBBH is a type of String with a lengh of 8
DLBM is a type of String with a lengh of 4
DLMC is a type of String with a lengh of 60
QSXZ is a type of String with a lengh of 3
QSDWDM is a type of String with a lengh of 19
QSDWMC is a type of String with a lengh of 60
ZLDWDM is a type of String with a lengh of 19
ZLDWMC is a type of String with a lengh of 60
GDLX is a type of String with a lengh of 2
KCLX is a type of String with a lengh of 2
DLBZ is a type of String with a lengh of 10
GDPDJ is a type of String with a lengh of 2
KCDLBM is a type of String with a lengh of 4
TKXS is a type of Double with a lengh of 19
TBMJ is a type of Double with a lengh of 19
XZDWMJ is a type of Double with a lengh of 19
LXDWMJ is a type of Double with a lengh of 19
TKMJ is a type of Double with a lengh of 19
TBDLMJ is a type of Double with a lengh of 19
PZWH is a type of String with a lengh of 254
BGJLH is a type of String with a lengh of 20
BGRQ is a type of Date with a lengh of 8
XZGDJFLY is a type of String with a lengh of 50
OBJECTID is a type of Integer with a lengh of 9
TBMJ_DIST is a type of Double with a lengh of 19
shape_Leng is a type of Double with a lengh of 19
shape_Area is a type of Double with a lengh of 19
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
 主要功能和特点:    1、自定义网站信息。    2、自定义数据库信息,可以对多个已经存在的数据库进行操作。    3、2.0A目前可以连接ACCESS、SQL Server两种类型数据库。    4、自定义数据库结构,以实现对任意数据库、任意字段、任意多数据的RSS降序输出和随机输出。    5、可以自定义输出条件。    6、自定义的数据库信息可以保存、修改、删除。    7、自定义的输出项目可以保存、修改、删除、生成(或更新)XML文件。    8、增强的查错程序,对于用户的输入错误有提示和一部分纠正功能。    9、根据自定义项目输出的XML文件为标准XML格式,可被所有RSS阅读器阅读。    10、输出的XML文件为静态文件,非动态存取,降低占用系统资源。    11、可以自定义存放XML文件的文件夹,可以自定义每一个项目生成的XML文件名。    12、完全支持后台生成静态页面网站的需求,可自定义静态页面的字段以及URL构成形式。    13、可以自定义FSO组件的名称,满足了那些修改过FSO组件名称的网站的需求。    14、所有RSS输出项目均可以随意调用,免去每次更新网站后需要手工输出的麻烦。  更新记录:  2005年6月27日:     v2.0A(SQL Server、Access通用版本)Build 20050627     增加了自定义FSO组件名称的功能,满足那些修改了FSO组件名称后无法使用本系统的用户的需求。     修正了数据库密码长度过短无法输入长密码的问题。     增加了所有输出项目可被自由调用实现自动更新RSS输出的功能。     同时发布Build 20050523到Build 20050627的数据库升级程序。   2005年5月23日:     v2.0A(SQL Server、Access通用版本)Build 20050523     增加了支持后台生成静态页面网站的RSS输出功能,使本系统的通用性进一步扩大。     修正了SQL Server登陆用户只能读取默认数据库的错误,可以读取该用户有读取权限的任意数据库。     同时发布Build 20050511到Build 20050523的数据库升级程序。
### 回答1: 可以使用C语言制作一个搜索关键字并能输出关键字所在字段的函数,具体步骤如下: 1. 定义函数名和参数。可以定义一个函数名为search_keyword,需要传入三个参数:待搜索的字符串数组(例如,char str[]),字段名称的字符串(例如,char field[]),以及待搜索的关键字(例如,char keyword[])。 2. 遍历待搜索的字符串数组,找到包含字段名称的字符串所在的位置,然后将该位置后面的字符串进行关键字搜索。 3. 在关键字搜索中,使用strstr函数查找是否包含关键字的子串。如果找到了,可以使用printf函数输出字段名称和关键字所在位置,或者将它们存储在另一个数组中。 4. 最后返回搜索结果,可以返回一个整数,表示找到的关键字数量。 下面是一个可能的函数实现代码: ``` int search_keyword(char str[], char field[], char keyword[]) { int found = 0; char *pos; pos = strstr(str, field); while (pos != NULL) { pos += strlen(field); pos = strstr(pos, keyword); if (pos != NULL) { printf("Found keyword '%s' in field '%s'\n", keyword, field); found++; } } return found; } ``` 这个函数使用了while循环和strstr函数,在字符串数组中查找字段名称,然后在该位置后面的字符串中查找关键字。如果找到了关键字,将输出它所在的字段名称和位置,并且返回找到的关键字数量。 ### 回答2: 使用C语言制作一个搜索关键字并能输出关键字所在字段的函数可以按照以下步骤进行: 1. 首先,定义一个结构体,用来表示一个字段。 ```c typedef struct { char fieldName[50]; // 字段名称 char fieldValue[500]; // 字段值 } Field; ``` 2. 然后,定义一个函数来从一系列字段中搜索关键字并输出所在字段。 ```c void searchKeyword(Field fields[], int numFields, char keyword[]) { int i, found = 0; for (i = 0; i < numFields; i++) { if (strstr(fields[i].fieldValue, keyword) != NULL) { printf("关键字 \"%s\" 在字段 \"%s\" 中找到。\n", keyword, fields[i].fieldName); found = 1; } } if (!found) { printf("未找到关键字 \"%s\"。\n", keyword); } } ``` 3. 最后,在主函数中创建一些字段,并调用搜索函数进行测试。 ```c int main() { Field fields[3]; // 假设有3个字段 strcpy(fields[0].fieldName, "标题"); strcpy(fields[0].fieldValue, "搜索引擎"); strcpy(fields[1].fieldName, "作者"); strcpy(fields[1].fieldValue, "John Doe"); strcpy(fields[2].fieldName, "内容"); strcpy(fields[2].fieldValue, "这是一个用C语言编写的搜索函数的例子。"); char keyword[50]; printf("请输入要搜索的关键字: "); scanf("%s", keyword); searchKeyword(fields, 3, keyword); return 0; } ``` 以上代码会输出包含关键字的字段,如果没有找到关键字,则会提示未找到。可以根据实际需求进行修改和扩展。 ### 回答3: 在使用C语言制作一个搜索关键字并能输出关键字所在字段的函数时,我们可以采用以下步骤: 1. 声明函数:首先,我们需要声明一个函数,函数名为searchKeyword。该函数需要传入两个参数:一个是要搜索的关键字,另一个是要搜索的字段(例如一个字符串数组)。函数的返回值可以是一个整数值,表示搜索到的关键字的位置(索引值)。 2. 字段遍历:在函数内部,我们需要使用循环遍历所给的字段。可以使用for循环来实现遍历,循环的次数为字段长度。 3. 关键字匹配:针对每个字段,我们需要使用字符串比较函数(例如strcmp)来判断该字段是否包含关键字。如果关键字出现在字段中,strcmp将返回0,否则返回其他值。 4. 输出结果:如果关键字匹配成功(即strcmp返回0),则可以将当前字段的位置作为返回值返回。否则,继续遍历下一个字段。如果所有字段都遍历完毕但没有找到匹配的关键字,则返回一个特定的标志(例如-1)表示搜索失败。 下面是一个示例代码的简单实现: ``` int searchKeyword(char keyword[], char fields[][50], int numFields) { int i; for (i = 0; i < numFields; i++) { if (strcmp(keyword, fields[i]) == 0) { return i; } } return -1; } ``` 在此示例中,我们传入关键字和字段数组作为参数,并使用strcmp函数逐个比较关键字和字段。如果匹配成功,则直接返回该字段的位置(索引值),如果所有字段都遍历完毕但没有找到匹配的关键字,则返回-1表示搜索失败。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值