python的windows 自动化【demo】
作者:互联网
- 【原始】打开记事本
def createFile(filename):
if os.path.exists(filename) == False:
open(filename, "a").close()
if os.path.getsize(filename):
pass
else:
f = open(filename, "a")
f.write("多喝水!!")
f.close()
def printTips(filename):
createFile(filename);
sub2 = subprocess.Popen(['notepad', filename]);
- 【win32com】打开记事本
import win32com.client
o = win32com.client.Dispatch("Excel.Application")
o.Visible = 1
o.Workbooks.Add() # for office 97 – 95 a bit different!
o.Cells(1,1).Value = "Hello"
标签:python,demo,createFile,filename,windows,win32com,path,close,open 来源: https://www.cnblogs.com/amize/p/15034735.html