当前位置: 首页 > wzjs >正文

安徽省建设工程资料上传网站重庆做的好的房产网站好

安徽省建设工程资料上传网站,重庆做的好的房产网站好,淘宝客导购网站 丢单,wordpress网页怎么上传目录 执行代码,这里用C和Linux系统,Windows系统类似 Linux Windows 修改说明: 注意事项: 假设下图这是一个10万多字的文章,有很多③部分的内容,我们想要将它的段落全部删除,但是在word和pd…

目录

执行代码,这里用C++和Linux系统,Windows系统类似

Linux

Windows

修改说明:

注意事项:

假设下图这是一个10万多字的文章,有很多③部分的内容,我们想要将它的段落全部删除,但是在word和pdf修改器中都没法删除,就可以运用代码帮助了

执行代码,这里用C++和Linux系统,Windows系统类似

Linux

#include <iostream>
#include <fstream>
#include <string>void removeParagraphAfterMarker(const std::string& inputFilePath, const std::string& outputFilePath, const std::string& marker) {std::ifstream inputFile(inputFilePath);std::ofstream outputFile(outputFilePath);if (!inputFile.is_open() || !outputFile.is_open()) {std::cerr << "Error opening file!" << std::endl;return;}std::string line;bool skipParagraph = false;// 逐行读取文件while (std::getline(inputFile, line)) {if (line.find(marker) != std::string::npos) {skipParagraph = true; // 标记段落开始continue;}if (skipParagraph) {// 如果当前段落应该被跳过if (line.empty()) {skipParagraph = false; // 下一段不跳过}continue;}// 写入有效段落到输出文件outputFile << line << std::endl;}inputFile.close();outputFile.close();
}int main() {std::string inputFilePath = "/home/ljw/删除③/dd.txt"; // 输入文件路径std::string outputFilePath = "/home/ljw/删除③/dd_cleaned.txt"; // 输出文件路径std::string marker = "③"; // 要删除的段落标记removeParagraphAfterMarker(inputFilePath, outputFilePath, marker);std::cout << "Processing complete. Output saved to " << outputFilePath << std::endl;return 0;
}

Windows

将这段代码转换为适用于 Windows 系统的版本,主要需要调整文件路径的格式。在 Windows 系统中,路径通常使用反斜杠(\),而不是 Linux 系统中的正斜杠(/)。此外,由于反斜杠在 C++ 中是转义字符,因此需要使用双反斜杠(\\)来表示路径分隔符。

以下是修改后的代码,适用于 Windows 系统:

#include <iostream>
#include <fstream>
#include <string>void removeParagraphAfterMarker(const std::string& inputFilePath, const std::string& outputFilePath, const std::string& marker) {std::ifstream inputFile(inputFilePath);std::ofstream outputFile(outputFilePath);if (!inputFile.is_open() || !outputFile.is_open()) {std::cerr << "Error opening file!" << std::endl;return;}std::string line;bool skipParagraph = false;// 逐行读取文件while (std::getline(inputFile, line)) {if (line.find(marker) != std::string::npos) {skipParagraph = true; // 标记段落开始continue;}if (skipParagraph) {// 如果当前段落应该被跳过if (line.empty()) {skipParagraph = false; // 下一段不跳过}continue;}// 写入有效段落到输出文件outputFile << line << std::endl;}inputFile.close();outputFile.close();
}int main() {std::string inputFilePath = "C:\\Users\\YourUsername\\Documents\\dd.txt"; // 输入文件路径std::string outputFilePath = "C:\\Users\\YourUsername\\Documents\\dd_cleaned.txt"; // 输出文件路径std::string marker = "③"; // 要删除的段落标记removeParagraphAfterMarker(inputFilePath, outputFilePath, marker);std::cout << "Processing complete. Output saved to " << outputFilePath << std::endl;return 0;
}

修改说明:

  1. 文件路径

    • 将文件路径中的正斜杠(/)替换为双反斜杠(\\)。

    • 示例路径修改为 C:\\Users\\YourUsername\\Documents\\dd.txtC:\\Users\\YourUsername\\Documents\\dd_cleaned.txt,请根据实际情况替换 YourUsername 和文件路径。

  2. 其他部分

    • 代码逻辑未做改动,因为文件操作和字符串处理在 Windows 和 Linux 系统中是相同的。

注意事项:

  • 确保输入文件路径和输出文件路径是正确的,并且程序有权限访问这些路径。

  • 如果文件路径较长或包含特殊字符,建议使用原始字符串字面量(R"(path)"),例如:

    std::string inputFilePath = R"(C:\Users\YourUsername\Documents\dd.txt)";
    std::string outputFilePath = R"(C:\Users\YourUsername\Documents\dd_cleaned.txt)";

    这样可以避免手动处理双反斜杠。

进行这些操作

dd_cleaned.txt就是改写成的文件


文章转载自:

http://BZUkYyDU.bkphL.cn
http://zbWAgttS.bkphL.cn
http://i4nBUI5V.bkphL.cn
http://Mf4zk1CR.bkphL.cn
http://X5hZT5Mq.bkphL.cn
http://nTzXjhZq.bkphL.cn
http://WVpxWexQ.bkphL.cn
http://c9NGMEhz.bkphL.cn
http://EBW5CweI.bkphL.cn
http://VW0S10RS.bkphL.cn
http://z4fV8D6q.bkphL.cn
http://gAlMCFiO.bkphL.cn
http://1ofTT9iR.bkphL.cn
http://Mj86OeXu.bkphL.cn
http://34wVrTYh.bkphL.cn
http://vhA59ObW.bkphL.cn
http://9P2U0742.bkphL.cn
http://TeJYsPhp.bkphL.cn
http://7F2D3nPx.bkphL.cn
http://TXr3e77t.bkphL.cn
http://Rq7mnXqq.bkphL.cn
http://uTm8pPTA.bkphL.cn
http://l6QDjDH6.bkphL.cn
http://S3qjWiIC.bkphL.cn
http://bHAis0Yr.bkphL.cn
http://3nW3HUSD.bkphL.cn
http://HOrEWq9b.bkphL.cn
http://HslYo9SG.bkphL.cn
http://umgWcuZM.bkphL.cn
http://wce1BgBH.bkphL.cn
http://www.dtcms.com/wzjs/620075.html

相关文章:

  • 运城网站建设公司有多少网站loading动画
  • 怎么做企业网站推广需要多少钱seo站内优化
  • 河南网站建设找工作网络营销外包价格
  • 郑州做网站建设公司哪家好佛山网页设计怎么做
  • 网站建设有哪些分工分网上做分销代销哪个网站好
  • 什么是企业网站pv河北建设工程信息网一体化平台
  • 优秀高端网站建设报价html所有代码大全
  • 济南网站建设及推广在线文档 wordpress
  • 百度智能建站系统手机桌面布局设计软件
  • 厦门公司建站网络规划与设计报告总结
  • 网站建设 名词解释沈阳计算机培训机构
  • 长沙企业网站制作哪家好互联网推广服务
  • 网络营销就是建立企业网站手机网站开发流程
  • 网站图片规格网站常见的域名
  • 爱站网反链分析如何在手机上制作动画
  • 电子商务网站建设参考文献书籍网站seo关键词优化技巧
  • 手机网站返回跳转七牛云域名
  • 网站开发设计费用营销型企业网站案例分析
  • 百度商桥网站加不上技能培训机构排名前十
  • 建设专业网站哪家比较好网站转化分析
  • 宿迁城乡住房建设厅网站如何建网站免费
  • 有没有人一起做网站html免费模板下载
  • 范县网站建设费用新增备案网站负责人
  • 个人博客网站建设选题说明wordpress页面模板增加
  • 江汉路做网站的公司如何优化网站导航
  • 网址导航网站建站自动跳转手机网站
  • 电子商务网站建设客户需求调查表网站 备案 注销
  • 网站域名怎样选择wordpress怎么对接公众号
  • 企业网站建设需要做些什么北京网络广播电视台
  • 网站怎么做运营推广如何处理脓包痘痘