pymongo 問題一覽

2021-09-02 04:34:21 字數 1035 閱讀 3115

1. 問題:

使用sort排序,**如下:

db.test.find().sort()  

遇到如下異常:

typeerror: if no direction is specified, key_or_list must be an instance of list  

解決方法:

db.test.find().sort([("name", 1), ("age" , 1)])  

原因:在python中只能使用列表進行排序,不能使用字典

2. 問題:

通過http請求objectid來進行資料操作時,無法查詢到資料,比如:

/posts/*********************

解決方法:

在後台接受到objectid後,對其實例化即可:

from bson.objectid import objectid  

objectid = objectid(str(*********************))  

1. 問題:

使用sort排序,**如下:

db.test.find().sort()  

遇到如下異常:

typeerror: if no direction is specified, key_or_list must be an instance of list  

解決方法:

db.test.find().sort([("name", 1), ("age" , 1)])  

原因:在python中只能使用列表進行排序,不能使用字典

2. 問題:

通過http請求objectid來進行資料操作時,無法查詢到資料,比如:

/posts/*********************

解決方法:

在後台接受到objectid後,對其實例化即可:

from bson.objectid import objectid  

objectid = objectid(str(*********************))  

linux 問題一覽

ubuntu安裝好後,root初始密碼 預設密碼 不知道,需要設定。1 先用安裝ubuntu的時候建立的使用者登入到系統 2 然後輸入命令 sudo passwd 摁回車 3 接下來會提示您 輸入新密碼,重複輸入密碼,最後提示您passwd password updated sucessfully ...

git 問題一覽(後續更新)

當本地建立git倉庫後遠端同樣建立了乙個新的git倉庫,然後兩個倉庫都有檔案導致這兩個倉庫無法關聯 於是呼叫git pull 出現如下錯誤 fatal refusing to merge unrelated histories 拒絕合併不相關的歷史 然後就可以使用 allow unrelated h...

HTML標記一覽

標記 型別譯名或意義 作 用備註 檔案標記 檔案宣告 讓瀏覽器知道這是 html 檔案 開頭 提供檔案整體資訊 標題 定義檔案標題,將顯示於瀏覽頂端 本文 設計檔案格式及內文所在 排版標記 說明標記 為檔案加上說明,但不被顯示 段落標記 為字 畫 等之間留一空白行 換行標記 令字 畫 等顯示於下一行...