0

我有这个 MongoDB 条目:

{"_id"=>BSON::ObjectId('527d17c9cef2ea265b000027'), "quote"=>"PERSUADERS. Spurs. The kiddey clapped his persuaders\r  to his prad but the traps boned him; the highwayman\r  spurred his horse hard, but the officers seized him."}

当我使用 Ruby 驱动程序获取此项目时,如下所示:

one = @db.collection('q').find_one({
    "_id" => BSON::ObjectId("527d17c9cef2ea265b000027")
})

puts one['quote']

我只得到最后一个之后的输出\r

  spurred his horse hard, but the officers seized him.

怎么来的?

4

1 回答 1

1

好吧,因为您将其输出到终端。and\r是一个控制字符,意思是“到行首”。所以它打印一些东西,然后返回并打印出来。

尝试这个:

p one['quote']

或者

puts one['quote'].inspect
于 2013-11-08T17:08:02.653 回答