天地一扁舟 2015-02-11 08:55 采纳率: 0%
浏览 2784
已结题

'GridFS' object has no attribute 'find'

File "E:\code\take.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'].fdroid
shot_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()

  • 写回答

1条回答 默认 最新

  • devmiao 2015-02-11 15:51
    关注

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

    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100