cmd语法变量赋值操作,注意=后面不能有空格,引号会被当前是内容的一部分,这你能忍
set name="C:AABB"
# -*- coding : utf-8 -*-
#python版本
print(sys.version)
print(sys.executable)
import os
import sys
import time
curDir = sys.path[0]
print("当前目录:", curDir)
#写文件,注意编码
def writeFile(filePath, content):
with open(filePath, 'w', encoding='gb2312') as f:
f.write(content)
writeFile(curDir + "\1.txt","hello 你好")
#读文件,注意编码
def readFile(filePath):
data = ""
with open(filePath, encoding='gb2312') as f:
lines = f.readlines()
for x in range(len(lines)):
if not "_0x51368401" in lines[x]:
data += lines[x]
return data
print(readFile(curDir + "\1.txt"))
#打开其他程序
# os.system('notepad 1.txt')
def runCmd(program,*args):
cmd = """ + program + """ + " "
for i in args:
cmd += i + " "
print("cmd-->", cmd)
os.system(cmd)
runCmd("exe","-s","-b")
#检测文件是否存在
#删除文件
def deleteFile(file):
if os.path.exists(file):
os.remove(file)
#创建文件夹
def makeDir(dir):
if not os.path.exists(dir):
os.makedirs(dir)
#文件路径,文件名,扩展
fileFullName = r"c:aab.txt"
(filePath,filename) = os.path.split(fileFullName)
(shotname,extension) = os.path.splitext(filename)
print(filePath) # c:aa
print(filename) # bb.txt
print(shotname) # bb
print(extension) # .txt
#重命名文件
def renameFile(filepath,newName):
(filePath,filename) = os.path.split(filepath)
newFileFullPath = filePath + "\" + newName
os.rename(filepath,newFileFullPath)
#暂停
os.system("pause")
time.sleep(2)
vs 后处理事件调用
if /I "$(ConfigurationName)" == "Release" "$(ProjectDir)afterdo.py"