每次去创建py文件的时候要好几步、还要再加上utf-8总感觉麻烦、就写了这个偷懒。
from sys import argv
import os
from os.path import exists
script, newFileName = argv
isExist = exists(newFileName)
print isExist
if isExist == True :
print "the file %s is haved." % newFileName
else :
print "no have"
theFile = open(newFileName, 'a+')
theFile.write("# -*- coding:utf-8 -*- \n")
theFile.close()
os.system( "open " + newFileName)
# create a new file write "# -*- coding:utf-8 -*- \n" and open it