Study Notes (16): 21 days clearance Python (Video Lesson only) - byte character by reading and reading and exception handling

Learning immediately: https://edu.csdn.net/course/play/24797/282196?utm_source=blogtoedu

the try: 
    # f = open ( 'Chinese .txt', 'W') 
    # Q binary format to read the contents of the file 
    f = open ( 'Chinese .txt', 'RB', True) 
    Data reached, f.read = () 
    Print ( STR (Data, 'UTF8')) 

the except OSError AS E: 
    Print (E) 
    Print (e.args) 
    Print (e.errno) 
    Print (e.strerror) 
the finally: 
    IF 'F' in Globals (): 
        f.close () 
# the try: 
# # F = Open ( 'Chinese .txt', 'W') 
# = F Open ( 'Chinese .txt', 'R & lt +', True, 'UTF8') 
# = Data reached, f.read () 
Print # (Data) 
# 
# AS OSError the except E: 
# Print (E) 
# Print (e.args) 
# Print (E.errno)
#     print(e.strerror)
# finally:
#     if 'f' in globals():
#         f.close()
Published 25 original articles · won praise 4 · Views 600

Guess you like

Origin blog.csdn.net/happyk213/article/details/105203103