FileStorage Read String Start With Number Need Quotation Mark 读取数字开头的字符串需要加引号
// 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" // Work
MyString: 123abc // NOT work
MyString: 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.
FileStorage Read String Start With Number Need Quotation Mark 读取数字开头的字符串需要加引号的更多相关文章
- This sample is for changing from “float64” to “int” for values did unmarshal using map[string]interface{}. When it did unmarshal using map[string]interface{}, a number with “int” was changed to “floa
This sample is for changing from “float64” to “int” for values did unmarshal using map[string]interf ...
- js或者jq的string类型或者number类型的相互转换及json对象与字符串的转换
1.将值乘以1,将string类型转为number类型 //算合计价值function summoney(money) { var zijin = $("#main_xm_dam09&quo ...
- java基础知识回顾之---java String final类普通方法的应用之“按照字节截取字符串”
/*需求:在java中,字符串“abcd”与字符串“ab你好”的长度是一样,都是四个字符.但对应的字节数不同,一个汉字占两个字节.定义一个方法,按照最大的字节数来取子串.如:对于“ab你好”,如果取三 ...
- java算法:统计数字-将数字转换成字符串,然后使用字符串String.valueOf()方法进行判断
题目: 计算数字 k 在 0 到 n 中的出现的次数,k 可能是 0~9 的一个值. 样例 样例 1: 输入: k = 1, n = 1 输出: 1 解释: 在 [0, 1] 中,我们发现 1 出现了 ...
- 判断一个string是否以数字开头
public static void main(String[] args) { Pattern pattern =null; String content = "30. ...
- switch case :在JDK 7中,又加入了对String类型的支持,从此不用再写If-Else来判断字符串了
switch的case语句可以处理int,short,byte,char类型的值, 因为short,byte,char都会转换成int进行处理,这一点也可以从生成的字节码看出. char a = 'e ...
- Long.parseLong(String s) 其中s必须是数字形式的字符串,才能运用该函数转化为长整型。
public class ConverTo { public static void main(String [] args) { String numberIn =args[0]; convertN ...
- 一道前端面试题:定义一个方法将string的每个字符串间加个空格返回,调用的方式'hello world'.spacify();
偶然在群里看到了这道题:定义一个方法将string的每个字符串间加个空格返回,调用的方式'hello world'.spacify(); 这道题主要是对JavaScript对象原型的考察.
- BUGFIX 09 - 记一次Java中String的split正则表达式匹配 - 引发`OutOfMemoryError: Java heap space`的oom异常 排查及解决 -Java根据指定分隔符分割字符串,忽略在引号里面的分隔符
问题简述 说白了,Java根据指定分隔符分割字符串,忽略在引号(单引号和双引号)里面的分隔符; oom压测的时候,正则匹配"(?=(?:[^\"]*\"[^\" ...
随机推荐
- Eclipse 项目红色叹号:Build Path Problem
Description Resource Path Location TypeA cycle was detected in the build path of project 'shgl-categ ...
- python 列表转为字典的两个小方法
1.现在有两个列表,list1 = ['key1','key2','key3']和list2 = ['1','2','3'],把他们转为这样的字典:{'key1':'1','key2':'2','ke ...
- apache一个IP多个站点的配置方法
在日常的网站发布中很多情况下都无法做到一个IP对应一个站点,在IP4的情况下IP的资源是相对有限的.然而作为最流行的Apache自然也考虑到这种情况,那么接下来看看apache服务器怎么配置一个IP多 ...
- fcitx-sogoupinyin下载地址和安装
伴随着Deepin 12.12 beta的发布,搜狗输入法也与我们见面了.在发布前几日Deepiner也通过各种途径向我们展示了搜狗Linux输入法,当然也掉足了胃口. 来自官方的截图: 当然令很多U ...
- MyBatis的foreach语句详解
foreach的主要用在构建in条件中,它可以在SQL语句中进行迭代一个集合.foreach元素的属性主要有 item,index,collection,open,separator,close.it ...
- C++类的成员函数使用的一些小总结
From: http://blog.csdn.net/xiayefanxing/article/details/7607506 这一阵做项目代码开发的时候,用到了在一个C++文件中使用另一个类的成员函 ...
- 数字型 、String字符串转换
Java代码 收藏代码 String str = "1,2,3,4,5,6" public int[] StringtoInt(String str) { int ret[] = ...
- struts2 标签问题----日期显示
对于要显示按照自己的意愿进行显示的话: <s:date name="date" format="yyyy-MM-dd HH:mm:ss.SSS" /> ...
- 一、HTML和CSS基础--HTML+CSS基础课程--第3部分
第五章 CSS样式基本知识 内联式css样式,直接写在现有的HTML标签中 CSS样式可以写在哪些地方呢?从CSS 样式代码插入的形式来看基本可以分为以下3种:内联式.嵌入式和外部式三种. 内联式cs ...
- 标准C实现基于TCP/IP协议的文件传输
上学期集成程序设计的课堂作业,对于理解TCP/IP实现还是挺有帮助的. TCP/IP编程实现远程文件传输在LUNIX中一般都采用套接字(socket)系统调用. 采用客户/服务器模式,其程序编写步骤如 ...