//QT
void ReadTxt()
{
QFile f("result.txt");
if (!f.open(QIODevice::ReadOnly|QIODevice::Text)) //打开指定文件
{
QMessageBox::about(NULL, "文件", "文件打开失败");
}
QTextStream txtInput(&f);
QString lineStr;
while (!txtInput.atEnd())
{
lineStr = txtInput.readLine(); //读取数据
qDebug()<<lineStr;
}
f.close();
}
#Python
import os
with open('result.txt', 'r') as f:
lines = f.readlines()
for line in lines:
print(line.rstrip()) #删除字符串末尾的空白