python 模糊查询

[复制链接]
查看11 | 回复3 | 2011-10-9 10:22:50 | 显示全部楼层 |阅读模式
字符串有个function叫startswith根据你的内容我提供一段代码for str in list:if str.startswith('a'):print "found it!",str楼主测试下哈,我用的是2.x。有问题再联系我~~蟒蛇小组祝您编程愉快!...
回复

使用道具 举报

千问 | 2011-10-9 10:22:50 | 显示全部楼层
print [x for x in list if x.find('a')==0]...
回复

使用道具 举报

千问 | 2011-10-9 10:22:50 | 显示全部楼层
list2 = [x for x in list if str(x).startswith('a')]...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行