C++
写入
#include <iostream>
#include <fstream>
using namespace std;
string fname="..\\..\\..\\xxx.txt";
ofstream pout(fname,ios_base::trunc);
pout<<outputnum<<" "<<endl;
pout.close();
读出
for(int i=0; i < num1 ;i++)
{
getline(ifs1, line);
if (line.size() == 0)
getline(ifs1, line);
istringstream iss(line);
unsigned char* row = descriptors1.ptr<uchar>(i);
iss >> temp.pt.x >> temp.pt.y >> a >> b >> c;
while (iss >> buf)
{
*row = stoi(buf);
row++;
}
}
ifs1.close();
python
with open('data.txt','w') as f: #设置文件对象
f.write(str)