python:if else 语句
#!/usr/bin/python
# -*- coding:utf-8 -*-
import os
fileName1 = 'a.txt'
if os.path.exists(fileName1):
file1 = open(fileName1,'w')
file1.write('file1 exists')
else:
file1 = open(fileName1,'w')
file1.write('file1 not exists')
#!/usr/bin/python
# -*- coding:utf-8 -*-
import os
fileName1 = 'a.txt'
if os.path.exists(fileName1):
file1 = open(fileName1,'w')
file1.write('file1 exists')
else:
file1 = open(fileName1,'w')
file1.write('file1 not exists')