python 在头文件添加 #include \"stdafx.h\"\r\n
import os
import shutil
#-*- coding:cp936 -*-
import codecs
from sys import argv
def replace_all_files(path):
cnt = 0
for root, dirs, files in os.walk(path):
for name in files:
if name.endswith(".cpp"):
f = codecs.open(os.path.join(root, name), "rb+")
text = f.read()
text1 = text
if text.find("\"stdafx.h\"")<0:
key = "#include \"stdafx.h\"\r\n"
if text[:3]==codecs.BOM_UTF8:
text1 = "%s%s%s" % (codecs.BOM_UTF8, key, text[3:])
else:
text1 = "%s%s" % (key, text)
f.seek(0)
f.truncate()
f.write(text1)
cnt = cnt+1
print "[%d] relpace File: " %cnt + os.path.join(root, name)
f.close()
if __name__ == "__main__":
try:
replace_all_files(argv[1])
except Exception, e:
print e.message
python 在头文件添加 #include \"stdafx.h\"\r\n的更多相关文章
- fatal error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "StdAfx.h"”? 解决方法
错误描述: fatal error C1010: 在查找预编译头时遇到意外的文件结尾.是否忘记了向源中添加“#include "StdAfx.h"”? 错误分析: 此错误发 ...
- 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "StdAfx.h"”?
在查找预编译头时遇到意外的文件结尾.是否忘记了向源中添加“#include "StdAfx.h"”? 右键选择该文件.cpp格式的->属性->预编译头,→ 不使用预编译 ...
- 错误描述:fatal error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "stdafx.h"”?(转)
错误分析: 此错误发生的原因是编译器在寻找预编译指示头文件(默认#include "stdafx.h")时,文件未预期结束.没有找到预编译指示信息的头文件"stdafx. ...
- VS2010编译错误:是否忘记了向源中添加“#include "stdafx.h
VS2010编译错误:是否忘记了向源中添加“#include "stdafx.h 编译提示:fatal error C1010: 在查找预编译头时遇到意外的文件结尾.是否忘记了向源中添加“# ...
- 是否忘记了向源中添加“#include "StdAfx.h"”?
错误分析 此错误发生的原因是编译器在寻找预编译指示头文件(默认#include "stdafx.h")时,文件未预期结束.没有找到预编译指示信息的头文件"stdafx.h ...
- twincat3新建cpp提示"在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "stdafx.h"
自己之前在windows下面写过一些c++的函数,想在倍福工控机上直接使用,发现添加了.cpp和.h文件后无法完成编译,会提示 在查找预编译头时遇到意外的文件结尾.是否忘记了向源中添加“#includ ...
- [C++]在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include StdAfx.h”
问题现象:在写好的.cpp文件后,编译报错.提示"你建立的工程使用了预编译功能, cpp最前边要留一行这样的内容:#include "StdAfx.h"问题原因:网上说是 ...
- C++---使用VS在C++编程中出现 fatal error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "stdafx.h"”?
啦啦啦,好久没写博客啦... 对于C++初学者来说适应一个新的编译器还是需要蛮长一段时间的,现在我就给你们说说标题所说的这个问题吧... 第一步:菜单--〉项目--〉设置,出现“项目设置”对话框,左边 ...
- vc编程中出现 fatal error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "stdafx.h"”?
解决办法菜单--〉项目--〉设置,出现“项目设置”对话框,左边展开项目,在“源文件”中找到出错的文件,然后在右边选择“C/C++”属性 页,在Category下拉框中选择“Precompiled He ...
随机推荐
- 我的Android进阶之旅------>解决DownloadManager报错java.lang.SecurityException: Invalid value for visibility: 2
1.问题描述 今天使用Android系统的DownloadManager进行下载操作时,爆了如下所示的错误: java.lang.RuntimeException: Unable to start s ...
- mysql以下c连接mysql数据库
1.安装sudo yum install mysql-devel 安装组件和库 2. #include <stdio.h> #include <stdlib.h> #incl ...
- Red Hat Enterprise Linux
以下是支持 Docker 的 RHEL 版本: Red Hat Enterprise Linux 7 (64-bit) Red Hat Enterprise Linux 6.5 (64-bit) 或更 ...
- git 遇到的问题
1.error: RPC failed; curl transfer closed with outstanding read data remaining 解决办法: git clone https ...
- python 各种魔法方法
目录 自定义序列 反射
- SQL基础三
一.SQL ORDER BY 子句 ORDER BY 语句用于对结果集进行排序,默认按照升序对记录进行排序,如果需要按照降序进行排序,需要在后面追加关键字DESC.应用如下: 原始的表:Orders表 ...
- Linux指令od和hexdump
Linux指令:od (octal dump) 示例用法:od -c hello Linux指令:od od命令用户通常使用od命令查看特殊格式的文件内容.通过指定该命令的不同选项可以以十进制.八进制 ...
- day2 笔记
while 条件: # 循环体 # 如果条件为真,那么循环体则执行 # 如果条件为假,那么循环体不执行 循环中止语句 如果在循环的过程中,因为某 ...
- The 2018 ACM-ICPC上海大都会赛 J Beautiful Numbers (数位DP)
题意:求小于等于N且能被自己所有位上数之和整除的数的个数. 分析:裸的数位dp.用一个三位数组dp[i][j][k]记录:第i位,之前数位之和为j,对某个mod余数为k的状态下满足条件的个数.这里mo ...
- jmeter常用插件安装
转载:http://www.cnblogs.com/danqiu/p/6119156.html 下载地址:http://jmeter-plugins.org/downloads/all/ PerfMo ...