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压测的时候,正则匹配"(?=(?:[^\"]*\"[^\" ...
随机推荐
- Verify Preorder Serialization of a Binary Tree
One way to serialize a binary tree is to use pre-order traversal. When we encounter a non-null node, ...
- POJ 2386
http://poj.org/problem?id=2386 这个题目与那个POJ 1562几乎是差不多的,只不过那个比这个输入要复杂一些 #include <stdio.h> #incl ...
- Win7下虚拟机个人使用小结:Virtual PC,VMware和VirtualBox
想来用了很多年的虚拟机了,换了Win7之后,种种原因又需要使用虚拟机,这里就简单介绍和比较一下. 点击小图看大图. Virtual PC: 如果想做Windows虚拟机的话,Virtual PC在之前 ...
- 如何关闭ie9烦人的提示信息?
①Q:如何关闭“IE 限制活动内容”的提示? A:去掉“IE 限制活动内容”的提示: 1. 找到IE的“Internet选项”: 2. 选择“高级”选项卡: 3. 在“设置”下,找到子标题“安全”,将 ...
- List对象分组排序算法
场景: List里面的对象是订单的节点,比如我们快递的物流状态,这个是需要有序的,所以需要根据订单号进行分组排序. import java.util.ArrayList; import java.ut ...
- 好玩儿的expect
前言 1> 借鉴里面的应用思想,使用断言提高代码的健壮性及维护性 2> 实现方式——不采用直接嵌入expect的方式,统一进行重写(提取常用断言方法,重新构造API) 官网介绍 https ...
- Android之jni入门
jni即java native interface,使用jni我们可以在JAVA中调用C代码,提高了效率,可以复用代码,可以灵活的应用于各种场景 怎么使用JNI 安装软件 1.NDK 用于将C代码编译 ...
- mysql-关于Unix时间戳(unix_timestamp)
unix_timestamp时间戳是自 1970 年 1 月 1 日(00:00:00 GMT)以来的秒数.它也被称为 Unix 时间戳(Unix Timestamp). Unix时间戳(Unix t ...
- 2016国产开源软件TOP100(Q1)
随着互联网的发展.开放标准的普及和虚拟化技术的应用等诸多IT新领域的创新及拓展,开源技术凭借其开放性.低成本.稳定性.灵活性.安全性和技术创新性等特点迅速走向成熟,逐步发展成为一种主流模式,日益改变着 ...
- ***PHP类型转换实例:$this->input->get()返回的结果是字符串类型(数字字符串转数字)
一个GET的REST API,请求有三个参数,且都是数字 用$this->input->get()方法获取后的结果是字符串,需要转换为数字:如果没有获取到数据,则会返回false,需要用e ...