天地一扁舟 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',调试下看看

    评论

报告相同问题?

悬赏问题

  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型