try
: : : 2016-01-01
:
try:, except ... as ...:
try:
file=open('eeee.txt','r') #
except Exception as e: # e
print(e)
"""
[Errno 2] No such file or directory: 'eeee.txt'
"""
No such file or directory. y, yssss
try:
file=open('eeee.txt','r+')
except Exception as e:
print(e)
response = input('do you want to create a new file:')
if response=='y':
file=open('eeee.txt','w')
else:
pass
else:
file.write('ssss')
file.close()
"""
[Errno 2] No such file or directory: 'eeee.txt'
do you want to create a new file:y
ssss #eeee.txt'ssss'
[try ]