- 【原始】打开记事本
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"