博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
FileStorage Read String Start With Number Need Quotation Mark 读取数字开头的字符串需要加引号...
阅读量:7074 次
发布时间:2019-06-28

本文共 1160 字,大约阅读时间需要 3 分钟。

//
Write data
FileStorage fs("test.yml", FileStorage::WRITE);    fs << "MyString" << "123abc";    fs.release();// Read data    FileStorage fs2("test.yml", FileStorage::READ);    string str = fs2["MyString"];    cout << "MyString = " << str << endl;    fs2.release();

In OpenCV, the FileStorage class can read and write data in the file. If you write the string "123abc" into the file, it will shows with quotation mark in the file. Now I want to read this string from the file into a string variable, you need to keep the quotation mark in the file which should be see as follows:

MyString: "123abc"

Now it can be read without problem, but if you change it to the followings:

MyString: 123abc

This will not gonna work this time, but if the string is not start with a number, it will work. I might treat it as a bug in the OpenCV. The three different situation is as follows:

MyString: "123abc"    // WorkMyString: 123abc      // NOT workMyString: abc123      // Work

In sum, when you want to read a string into a variable, if it starts with a number, you need to add the quotation marker to the whole string in the file.

本文转自博客园Grandyang的博客,原文链接:,如需转载请自行联系原博主。

你可能感兴趣的文章
统计数据库大小的方法
查看>>
PHP递归遍历文件夹
查看>>
用户系列之五:用户SID查看之终结版
查看>>
ubuntu 11.10下载和编译Android源码
查看>>
千兆级LTE的一小步,5G之路的一大步
查看>>
跟我一起写 Makefile(一)
查看>>
管理日志-原创理论工具--技能方格图
查看>>
MPLS TE第一步:创建基本TE隧道
查看>>
windows中禁止U盘写入
查看>>
Bash技巧总结
查看>>
在窗体中添加标签Label、Icon图标
查看>>
Perl脚本学习笔记(一)
查看>>
基于BIND实现DNS的解析、主从、子域、请求转发、访问控制
查看>>
Oracle Number用法
查看>>
nat
查看>>
基于Cisco技术的MPLS原理以及应用实现[一]
查看>>
iPhone/Mac Objective-C内存管理原理
查看>>
极速理解设计模式系列:14.轻量级模式(Flyweight Pattern)
查看>>
Resin HTTPS 安装指南
查看>>
无法加入域
查看>>