场景:

pymongo 查询数据库的时候报错。

for gscode in GSList_StockPool_Mongo_MktStop:

  self._collection_flash.find({"ymd": nDateNow, "gscode": gscode}).count()

原因:

不是utf-8编码,gscode 取到的中文是乱码。

解决方法:

编码改为utf-8。

  

bson.errors.InvalidStringData: strings in documents must be valid UTF-8的更多相关文章

  1. python unicode字节串转成中文问题

    如题,其实我的问题很简单,就是在写爬虫的时候拿到网页的信息包含类似“\u65b0\u6d6a\u5fae\u535a\u6ce8\u518c”的字符串,实际上这是unicode的中文编码,对应的中文为 ...

  2. MongoDB - Introduction to MongoDB, Documents

    MongoDB stores data records as BSON documents. BSON is a binary representation of JSON documents, th ...

  3. abiword Related Pages

    Application Framework The 'af' directory contains all source code for the cross-platform application ...

  4. go语言操作mongodb

    Install the MongoDB Go Driver The MongoDB Go Driver is made up of several packages. If you are just ...

  5. nosql_action

    ps -aux  查当前端口占用 connecting to: test > show dbs local .078125GB testphp .203125GB > use testph ...

  6. Python2.7.6标准库内建函数

        Built-in Functions     abs() divmod() input() open() staticmethod() all() enumerate() int() ord( ...

  7. 【GoLang】GO语言系列--002.GO语言基础

    002.GO语言基础 1 参考资料 1.1 http://www.cnblogs.com/vimsk/archive/2012/11/03/2736179.html 1.2 https://githu ...

  8. ExtJS4笔记 Data

    The data package is what loads and saves all of the data in your application and consists of 41 clas ...

  9. andriod 开发记录apidemos 错误解决

    android sdk 里面有simple 文件夹里面有对应的demo  但是拿出来esplise运行报错 解决方案如下 右键错误代码goto,给对应错误的单引号前加 \ 原文http://stack ...

随机推荐

  1. Hspice仿真打印某个子模块中所有信号信息

    简单的说就是在你要打印的子模块中加一句:.probe v(*) i(*)就可以了,这个子模块的每一个实例都会被打印出来.

  2. 如何用adb抓取log?

    在Androidclient的測试过程中,有时候我们会遇到闪退等异常情况. 这时我们能够通过adb抓取log.从而给开发提供很多其它信息. 一.下载ADB.exe     在网上搜索"adb ...

  3. Django修改用户名密码的方法

    1.python manage.py shell 2.from django.contrib.auth.models import User 3.user=User.objects.get(usern ...

  4. Ubuntu和centos下查看包的安装路径

    安装包后,如何查看安装的具体路径? Ubuntu下: dpkg -L  <包名> CentOS下: rpm -ql   <包名> 助记: l为list的首字母. q为query ...

  5. iptables清空链的规则

    建立iptables时,首先需要情况系统默认的规则(如果有),这样能够保证iptables按照自己的想法运行. iptables -F   //清空链规则,但不会情况子链,也不会清空表的默认策略 ip ...

  6. 微信H5支付.NET版本备忘

    微信H5支付.NET版本备忘

  7. [k8s]subpath解决cm覆盖目录问题

    参考 发现cm老覆盖容器原有目录里的内容,后来不得不通过in -s的方式来搞cm, 先将cm挂到/tmp下,然后ln -s文件到指定目录. 后来发现个cm的subpath特性可以解决这个问题 写了bu ...

  8. Wireshark分析网络慢

        tcp.analysis.retransmission tcp.flags.reset==1

  9. 【Android】11.2 通过重写对应的方法保存和恢复实例的状态

    分类:C#.Android.VS2015: 创建日期:2016-02-21 一.简介 通过重写(也叫回调)对应的方法来管理Activity的生命周期,比如用户旋转屏幕时应用程序要能自动保存和恢复实例的 ...

  10. android笔记-----消息提示

    在/res/values目录下的文件中定义要显示的字符串,主要是考虑到后期可能需要换成英文之类的 <string name="login_checkBlank">用户名 ...