由于项目需要删除第一个字符,然后按照相同顶格显示,如下:
v -279.268005 37.345402 -2.081520
v -280.971985 37.074699 -1.353890
v -279.015991 44.888100 -1.609860
需要转化为:
-279.268005 37.345402 -2.081520
-280.971985 37.074699 -1.353890
-279.015991 44.888100 -1.609860
所以写了个C++版本读入然后生成新的txt文档
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
int main()
{
ifstream in("1.txt");
ofstream out("2.txt");
string str;
string ans;
bool once;
while (getline(in, str))
{
if (str[0] == 'v')
{
once = false;
for (int i = 1; i < str.length(); i++)
{
if (once || str[i] != ' ')
{
ans += str[i];
once = true;
}
}
}
else
ans = str;
out << ans;
out << '\n';
ans.clear();
}
in.close();
out.close();
cin.get();
}