场景:

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. (三)RocketMq入门之独立线程处理业务

    一.示例代码 这段代码实现了一个独立线程监听在一个特殊的消息队列上,一旦收到消息就处理并发送给MQ,然后推送给所有的消费者. import com.alibaba.rocketmq.client.ex ...

  2. JavaScript - 返回头部

    制作浮动top $(window).scroll( function() { var scrollValue=$(window).scrollTop(); scrollValue > 600 ? ...

  3. 定制WinEdt 优化Latex输入

    定制WinEdt 优化Latex输入 ---原文转载地址:http://www.mamicode.com/info-detail-342716.html ---推荐winedt功能定制使用-说明文档: ...

  4. 自己写的一个操作Mysql的简单的实例

    #include <WinSock.h> #include <stdio.h> #include <iostream> #include <windows.h ...

  5. 【Android】3.5 示例5--多地图展示

    分类:C#.Android.VS2015.百度地图应用: 创建日期:2016-02-04 3.5 示例5--多地图展示 一.简介 地图控件自v2.3.5版本起,支持多实例,即开发者可以在一个页面中建立 ...

  6. 经纬度、时分秒转换的C#类

    一:新建一个包含经纬度.时间转换的类optaDataConvert public class optaDataConvert { /// <summary> /// 时间转换 /// &l ...

  7. C++ 11 std::function std::bind使用

    cocos new 出新的项目之后,仔细阅读代码,才发现了一句3.0区别于2.0的代码: auto closeItem = MenuItemImage::create( "CloseNorm ...

  8. CEdit 控制键盘操作

    写在前面的话:在工作中要实现这样一个功能,在一个树形控件中选择要发送消息的客户,添加到一个列表控件中,点击确定跳到一个信息发送页面如下图,在发送人编辑框中显示选择的客户,要实现的就是即允许用户删除用户 ...

  9. 在js代码中调用jsp的变量

    <% int coblid=Integer.parseInt(request.getParameter("blid")); %> <script> var ...

  10. android——inflater 用法(转)

    在实际开发中LayoutInflater这个类还是非常有用的,它的作用类似于findViewById().不同点是LayoutInflater是用来找res/layout/下的xml布局文件,并且实例 ...