确认过眼神,遇见对的人
Tool one: MATLAB
function lower: lower(str)–将字母变成小写
function findstr: index = findstr(str1, str2)–从str1中寻找str2,并返回位置
function dir:
List = dir(pathstr)–列出当前目录下所有文件和子文件夹
List = dir(‘*.m’)–返回后缀为m的文件和子文件夹
dir的返回值是结构体,不排序:
function exist: exist(var)–判断var是否存在,可以是变量、文件等等
function isdir/mkdir isdir(path)–判断路径是否是目录mkdir(path)–创建目录
读取文件中特定行
%% 读取特定行, 跳过499*1081行,读取1081*4数据
fid = fopen(laserFile,'r');
laser = cell2mat(textscan(fid,'%f %f %f %f',1081,'HeaderLines',500*1081));
Tool two: VS/C++
void getFiles(std::string path, std::vector<std::string>& files, std::vector<std::string>& catalogs)
{
//文件句柄
long hFile = 0;
//文件信息
struct _finddata_t fileinfo;
std::string p;
if ((hFile = _findfirst(p.assign(path).append("\\*").c_str(), &fileinfo)) != -1)
{
do
{
//如果是目录,加入目录列表
if ((fileinfo.attrib & _A_SUBDIR))
{
if (strcmp(fileinfo.name, ".") != 0 && strcmp(fileinfo.name, "..") != 0)
{
//getFiles(p.assign(path).append("\\").append(fileinfo.name), files);
catalogs.push_back(p.assign(path).append("\\").append(fileinfo.name));
}
}
else
{
files.push_back(p.assign(path).append("\\").append(fileinfo.name));
}
} while (_findnext(hFile, &fileinfo) == 0);
_findclose(hFile);
}
}
Tool three: Python
import os
if os.path.exists(path):
files = os.listdir(path)
else:
message = "sorry, can not find '%s' file."
print(message % xml_path)
return
for file in files:
#判断是否是正确的文件
(file_name,extension) = os.path.splitext(file)
if extension != '.xml':
print(file + ' is not xml file.')
continue
print(file)
我的故事都是关于你