python-'GridFS' object has no attribute 'find'

问题描述

'GridFS' object has no attribute 'find' 1C
File ""E:codetake.py"" line 52 in take for s in fs.find({'packageName':doc['_id']}): AttributeError: 'GridFS' object has no attribute 'find' 请问各位朋友我python中报这个错误是什么原因,该如何解决呢?
下面是我的代码:
#!/bin/env/python

-*coding: utf-8 --

import pymongo
import pymongo
import gridfs
import sys
import copy
reload(sys)
sys.setdefaultencoding('utf-8')
import os

from gridfs import *

def take():

client = pymongo.MongoClient(host='192.168.213.225')info_collection = client['up'].fdroidshot_db2 = client['shots']shot_db = client['os_shot']#fs = gridfs.GridFS(shot_db2)f = gridfs.GridFS(shot_db)fs = gridfs.GridFS(shot_db2)text=''for doc in info_collection.find(        {            'interfaces': {'$exists': True}            # '_id':""apps.droidnotify""            # '_id':""com.appengine.paranoid_android.lost""                                                   }    ).limit(10).skip(0):    cnt=-1     dir_name = doc['_id']    try:        os.makedirs(dir_name)    except:        pass      with open(os.path.join(dir_name'sequence.txt')'w') as sequence_f:        for page in doc['interfaces']:            sequence_f.write(str(page['id'])+' '+str(page['parent'])+'n')             cnt+=1            for node in page['viewnodes']:                if type(node['text'])==type(u'') and len(node['text'])>1 and node['height']!=0 and node['width']!=0:                    text+=node['text'].lower().encode('utf-8')+' '            with open(os.path.join(dir_name str(cnt)+'.txt') 'w+b') as wf:                wf.write(text)                text=''        if doc['os']==1 :            for s in f.find({'packageName':doc['_id']}):                with open(os.path.join(dir_name s.filename) 'w+b') as wf:                    wf.write(s.read())        else:            for s in fs.find({'packageName':doc['_id']}):                with open(os.path.join(dir_name  s.filename) 'w+b' ) as wf:                    wf.write(s.read())        #else:        # rf=fs            # for s in fs.find({'packageName':doc['_id']}):            #     with open(os.path.join(dir_name s.filename) 'w+b') as wf:            #         wf.write(s.read())

take()

解决方案

'GridFS' 中没有属性 'find',调试下看看

时间: 2024-10-26 22:16:58

python-'GridFS' object has no attribute 'find'的相关文章

python 出现dict' object has no attribute 'key'

问题描述 python 出现dict' object has no attribute 'key' def make_omelet(omelet_type): def get_omelet_ingredients(omelet_name): ingredients={"egg":2,"milk":1} if omelet_name=="cheese": ingredients["cheddar"]=2 elif omelet_

python新手求助-初学者python 'str' object has no attribute 'vals' 怎么解决啊

问题描述 初学者python 'str' object has no attribute 'vals' 怎么解决啊 代码如下 import sqlite3 def convert(value): if value.startswith('~'): return value.strip('~') if not value: value = '0' return float(value) conn=sqlite3.connect('food.db') curs=conn.cursor() try:

提示AttributeError: 'module' object has no attribute 'HTTPSHandler'解决方法

今天在新机器上安装sqlmap,运行提示AttributeError: 'module' object has no attribute 'HTTPSHandler' 网上找了找资料,发现一篇文章http://paltman.com/2007/11/15/getting-ssl-support-in-python-251/ 输入如下命令: 1 2 3 4 5 6 wget http://www.openssl.org/source/openssl-0.9.8g.tar.gz tar zxf op

AttributeError: 'dict_values' object has no attribute 'translate'

/***************************************************************************************** * AttributeError: 'dict_values' object has no attribute 'translate' * 说明: * 由于目前使用的是Python3,在解读MySQL的ORM库的时候,结果直接遇到这个错误. * * 2016-10-13 深圳 南山平山村 曾剑锋 **********

AttributeError: 'module' object has no attribute 'TornadoAsyncNotifier'

/*************************************************************************** * AttributeError: 'module' object has no attribute 'TornadoAsyncNotifier' * 说明: * Tony在用mkdocs的时候遇到这个错误,找一些资料,解决一下. * * 2016-10-28 深圳 南山平山村 曾剑锋 *****************************

python错误:AttributeError: 'module' object has no attribute 'setdefaultencoding'问题的解决方法_python

Python的字符集处理实在蛋疼,目前使用UTF-8居多,然后默认使用的字符集是ascii,所以我们需要改成utf-8 查看目前系统字符集 复制代码 代码如下: import sys print sys.getdefaultencoding() 执行: 复制代码 代码如下: [root@lee ~]# python a.py ascii 修改成utf-8 复制代码 代码如下: import sys   sys.setdefaultencoding('utf-8')   print sys.get

Python提示AttributeError: 'module' object has no attribute 'XXX'的问题

问题描述 在运行py脚本时报错AttributeError: 'module' object has no attribute 'urlopen'. 排错,模块名拼写正确,方法urlopen也存在. 代码断点运行,没问题. 方谷歌之. 解决方法 1.在命名py脚本时,不要和python的预留字等类似或者相同. 2.每次py脚本运行时均会产生一个pyc文件.如果产生了则在代码不更新的时候依旧会走pyc.所以也一并要删除. 如下Python代码,执行时报错"AttributeError: 'modu

Python3下机器学习实战KNN代码出现AttributeError: ‘dict’ object has no attribute错误

出现错误的代码时: result = sorted(classCount.iteritems(), key=operator.itemgetter(1), reverse=True) 错误显示: AttributeError: 'dict' object has no attribute 'iteritems' 之所以会出现上述错误是因为python3中已经没有这个属性,直接改为items即可: result = sorted(classCount.items(), key=operator.i

[Python]attributeError:'module' object has no attribute 'dump'

[问题] [代码] 文件名:pickle.py # coding=utf-8 #持久存储 import pickle #b 以二进制的模式打开文件 with open('mydata.pickle','wb') as mysavedata: #用dump保存数据 pickle.dump([1,2,'three'],mysavedata) #b 以二进制的模式打开文件 with open('mydata.pickle','rb') as myreaddata: #使用load恢复数据 list =