Python Try Except: пошаговое руководство

–û–ø–µ—Ä–∞—Ç–æ—Ä Python try & hellip; except –ø–µ—Ä–µ—Ö–≤–∞—Ç—ã–≤–∞–µ—Ç –∏—Å–∫–ª—é—á–µ–Ω–∏–µ. –û–Ω –∏—Å–ø–æ–ª—å–∑—É–µ—Ç—Å—è –¥–ª—è –ø—Ä–æ–≤–µ—Ä–∫–∏ –∫–æ–¥–∞ –Ω–∞ –Ω–∞–ª–∏—á–∏–µ –æ—à–∏–±–∫–∏, –∑–∞–ø–∏—Å–∞–Ω–Ω–æ–π –≤ " try " —É—Ç–≤–µ—Ä–∂–¥–µ–Ω–∏–µ. –ü—Ä–∏ –æ–±–Ω–∞—Ä—É–∂–µ–Ω–∏–∏ –æ—à–∏–±–∫–∏ —Å–æ–¥–µ—Ä–∂–∏–º–æ–µ —Ç–µ–≥–∞ " except " –±–ª–æ–∫ –∑–∞–ø—É—Å–∫–∞—é—Ç—Å—è.

–í—ã –º–æ–∂–µ—Ç–µ –ø—Ä–æ—Ç–µ—Å—Ç–∏—Ä–æ–≤–∞—Ç—å –∫–æ–Ω–∫—Ä–µ—Ç–Ω—ã–π –±–ª–æ–∫ –∫–æ–¥–∞, —á—Ç–æ–±—ã —É–±–µ–¥–∏—Ç—å—Å—è, —á—Ç–æ –æ–Ω —Ä–∞–±–æ—Ç–∞–µ—Ç –ø—Ä–∞–≤–∏–ª—å–Ω–æ, –ø—Ä–µ–∂–¥–µ —á–µ–º —Ä–∞–∑—Ä–µ—à–∏—Ç—å –≤—ã–ø–æ–ª–Ω–µ–Ω–∏–µ –æ—Å—Ç–∞–ª—å–Ω–æ–π –ø—Ä–æ–≥—Ä–∞–º–º—ã. –ù–∞–ø—Ä–∏–º–µ—Ä, –ø—Ä–µ–¥–ø–æ–ª–æ–∂–∏–º, —á—Ç–æ –≤—ã –Ω–∞–ø–∏—Å–∞–ª–∏ –±–æ–ª—å—à–æ–π –æ–±—ä–µ–º –Ω–æ–≤–æ–≥–æ –∫–æ–¥–∞ –¥–ª—è –ø—Ä–æ–≥—Ä–∞–º–º—ã. –ü—Ä–µ–∂–¥–µ —á–µ–º –∑–∞–ø—É—Å–∫–∞—Ç—å –æ—Å—Ç–∞–ª—å–Ω—É—é —á–∞—Å—Ç—å –ø—Ä–æ–≥—Ä–∞–º–º—ã, –≤—ã –¥–æ–ª–∂–Ω—ã —É–±–µ–¥–∏—Ç—å—Å—è, —á—Ç–æ –æ–Ω —Ä–∞–±–æ—Ç–∞–µ—Ç.

–ë–ª–æ–∫–∏ try & hellip; except –ø–æ–∑–≤–æ–ª—è—é—Ç –≤–∞–º –ø—Ä–æ—Ç–µ—Å—Ç–∏—Ä–æ–≤–∞—Ç—å –≤–∞—à –∫–æ–¥ –∏ –æ–±—Ä–∞–±–æ—Ç–∞—Ç—å –∏—Å–∫–ª—é—á–µ–Ω–∏–µ, –µ—Å–ª–∏ –æ–Ω–æ –≤–æ–∑–Ω–∏–∫–Ω–µ—Ç. –í—ã –º–æ–∂–µ—Ç–µ –¥–æ–±–∞–≤–∏—Ç—å –æ–ø–µ—Ä–∞—Ç–æ—Ä—ã finally –∏ else –¥–ª—è –∑–∞–ø—É—Å–∫–∞ –¥–æ–ø–æ–ª–Ω–∏—Ç–µ–ª—å–Ω–æ–≥–æ –∫–æ–¥–∞ –≤ –∑–∞–≤–∏—Å–∏–º–æ—Å—Ç–∏ –æ—Ç —Ä–µ–∑—É–ª—å—Ç–∞—Ç–∞ –±–ª–æ–∫–∞ try & hellip; except.

–í —ç—Ç–æ–º —Ä—É–∫–æ–≤–æ–¥—Å—Ç–≤–µ –º—ã –ø–æ–≥–æ–≤–æ—Ä–∏–º –æ —Ç–æ–º, –∫–∞–∫ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å try and except –≤ Python. –ú—ã –æ–±—Ä–∞—Ç–∏–º—Å—è –∫ –ø—Ä–∏–º–µ—Ä—É, —á—Ç–æ–±—ã –≤—ã –º–æ–≥–ª–∏ –±—ã—Å—Ç—Ä–æ –ø—Ä–∏—Å—Ç—É–ø–∏—Ç—å –∫ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞–Ω–∏—é try and except.

–û–±–Ω–æ–≤–ª–µ–Ω–∏–µ –æ—à–∏–±–æ–∫ –∏ –∏—Å–∫–ª—é—á–µ–Ω–∏–π Python

–í Python –≤—ã –º–æ–∂–µ—Ç–µ —Å—Ç–æ–ª–∫–Ω—É—Ç—å—Å—è —Å –¥–≤—É–º—è —Ç–∏–ø–∞–º–∏ –æ—à–∏–±–æ–∫: —Å–∏–Ω—Ç–∞–∫—Å–∏—á–µ—Å–∫–∏–µ –æ—à–∏–±–∫–∏ –∏ –∏—Å–∫–ª—é—á–µ–Ω–∏—è.

—Å–∏–Ω—Ç–∞–∫—Å–∏—á–µ—Å–∫–∏–µ –æ—à–∏–±–∫–∏ Python - —ç—Ç–æ —Ç–∏–ø –æ—à–∏–±–∫–∏, –∫–æ—Ç–æ—Ä–∞—è –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç—Å—è –ø—Ä–∏ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞–Ω–∏–∏ –Ω–µ–ø—Ä–∞–≤–∏–ª—å–Ω–æ–≥–æ —Å–∏–Ω—Ç–∞–∫—Å–∏—Å–∞. –ù–∞–ø—Ä–∏–º–µ—Ä, –µ—Å–ª–∏ –≤—ã –Ω–∞–ø–∏—à–µ—Ç–µ —Ü–∏–∫–ª while True –±–µ–∑ –¥–≤–æ–µ—Ç–æ—á–∏—è –≤ –∫–æ–Ω—Ü–µ, –ø—Ä–æ–≥—Ä–∞–º–º–∞ —Å–æ–æ–±—â–∏—Ç –æ–± –æ—à–∏–±–∫–µ.

–ü—Ä–∏ –≤–æ–∑–Ω–∏–∫–Ω–æ–≤–µ–Ω–∏–∏ —Å–∏–Ω—Ç–∞–∫—Å–∏—á–µ—Å–∫–∏—Ö –æ—à–∏–±–æ–∫ –æ–Ω–∏ –≤–µ—Ä–Ω—É—Ç –∏–º—è —Ñ–∞–π–ª–∞, —Å—Ç—Ä–æ–∫—É —á–∏—Å–ª–æ –∏ –∏–Ω–¥–∏–∫–∞—Ç–æ—Ä —Ç–æ–≥–æ, –≥–¥–µ –º–æ–∂–µ—Ç –ø—Ä–∏—Å—É—Ç—Å—Ç–≤–æ–≤–∞—Ç—å –æ—à–∏–±–∫–∞.

–ò—Å–∫–ª—é—á–µ–Ω–∏—è - —ç—Ç–æ —Ç–∏–ø –æ—à–∏–±–∫–∏, –ø—Ä–∏ –∫–æ—Ç–æ—Ä–æ–π –∫–æ–¥ –º–æ–∂–µ—Ç –∏–º–µ—Ç—å –ø—Ä–∞–≤–∏–ª—å–Ω—ã–π —Å–∏–Ω—Ç–∞–∫—Å–∏—Å, –Ω–æ –≤—Å–µ –∂–µ —Å–æ–¥–µ—Ä–∂–∞—Ç—å –ø—Ä–æ–±–ª–µ–º—É. –°—É—â–µ—Å—Ç–≤—É–µ—Ç –º–Ω–æ–≥–æ —Ç–∏–ø–æ–≤ –∏—Å–∫–ª—é—á–µ–Ω–∏–π, –Ω–æ –Ω–µ–∫–æ—Ç–æ—Ä—ã–µ –∏–∑ –Ω–∞–∏–±–æ–ª–µ–µ —Ä–∞—Å–ø—Ä–æ—Å—Ç—Ä–∞–Ω–µ–Ω–Ω—ã—Ö, —Å –∫–æ—Ç–æ—Ä—ã–º–∏ –≤—ã –º–æ–∂–µ—Ç–µ —Å—Ç–æ–ª–∫–Ω—É—Ç—å—Å—è, –≤–∫–ª—é—á–∞—é—Ç: ArithmeticError, ImportError, ZeroDivisionError, NameError , –∏ TypeError.

81% —É—á–∞—Å—Ç–Ω–∏–∫–æ–≤ –∑–∞—è–≤–∏–ª–∏, —á—Ç–æ –æ–Ω–∏ –ø–æ—á—É–≤—Å—Ç–≤–æ–≤–∞–ª–∏ —Å–µ–±—è –±–æ–ª–µ–µ —É–≤–µ—Ä–µ–Ω–Ω—ã–º–∏ –≤ —Å–≤–æ–∏—Ö –ø–µ—Ä—Å–ø–µ–∫—Ç–∏–≤–∞—Ö —Ç—Ä—É–¥–æ—É—Å—Ç—Ä–æ–π—Å—Ç–≤–∞ –≤ —Å—Ñ–µ—Ä–µ –≤—ã—Å–æ–∫–∏—Ö —Ç–µ—Ö–Ω–æ–ª–æ–≥–∏–π –ø–æ—Å–ª–µ –ø–æ—Å–µ—â–µ–Ω–∏—è —É—á–µ–±–Ω–æ–≥–æ –ª–∞–≥–µ—Ä—è. –ü–æ–ª—É—á–∏—Ç–µ –ø—Ä–∏–≥–ª–∞—à–µ–Ω–∏–µ –Ω–∞ —É—á–µ–±–Ω—ã–π –ª–∞–≥–µ—Ä—å —Å–µ–≥–æ–¥–Ω—è.

–°—Ä–µ–¥–Ω–∏–π –≤—ã–ø—É—Å–∫–Ω–∏–∫ —É—á–µ–±–Ω–æ–≥–æ –ª–∞–≥–µ—Ä—è –ø–æ—Ç—Ä–∞—Ç–∏–ª –º–µ–Ω–µ–µ —à–µ—Å—Ç–∏ –º–µ—Å—è—Ü–µ–≤ –Ω–∞ –ø–µ—Ä–µ—Ö–æ–¥–Ω—É—é –∫–∞—Ä—å–µ—Ä—É, –æ—Ç –Ω–∞—á–∞–ª–∞ —É—á–µ–±–Ω–æ–≥–æ –ª–∞–≥–µ—Ä—è –¥–æ –ø–æ–∏—Å–∫–∞ —Å–≤–æ–µ–π –ø–µ—Ä–≤–æ–π —Ä–∞–±–æ—Ç—ã.

–ó–∞—è–≤–ª–µ–Ω–∏–µ Python try & hellip; except –∑–∞–ø—É—Å–∫–∞–µ—Ç –∫–æ–¥ –≤ —Ä–∞–∑–¥–µ–ª–µ " try " —É—Ç–≤–µ—Ä–∂–¥–µ–Ω–∏–µ. –ï—Å–ª–∏ —ç—Ç–æ—Ç –∫–æ–¥ –Ω–µ –≤—ã–ø–æ–ª–Ω—è–µ—Ç—Å—è —É—Å–ø–µ—à–Ω–æ, –ø—Ä–æ–≥—Ä–∞–º–º–∞ –æ—Å—Ç–∞–Ω–æ–≤–∏—Ç—Å—è –Ω–∞ —Å—Ç—Ä–æ–∫–µ, –≤—ã–∑–≤–∞–≤—à–µ–π –æ—à–∏–±–∫—É, –∏ " except " –∫–æ–¥ –±—É–¥–µ—Ç –∑–∞–ø—É—â–µ–Ω.

–ë–ª–æ–∫ try –ø–æ–∑–≤–æ–ª—è–µ—Ç –ø—Ä–æ–≤–µ—Ä–∏—Ç—å –±–ª–æ–∫ –∫–æ–¥–∞ –Ω–∞ –Ω–∞–ª–∏—á–∏–µ –æ—à–∏–±–æ–∫. –ë–ª–æ–∫ except –ø–æ–∑–≤–æ–ª—è–µ—Ç –≤–∞–º –æ–±—Ä–∞–±–æ—Ç–∞—Ç—å –æ—à–∏–±–∫—É —Å –ø–æ–º–æ—â—å—é –æ–ø—Ä–µ–¥–µ–ª—è–µ–º–æ–≥–æ –ø–æ–ª—å–∑–æ–≤–∞—Ç–µ–ª–µ–º –æ—Ç–≤–µ—Ç–∞.

–í–æ—Ç —Å–∏–Ω—Ç–∞–∫—Å–∏—Å –±–ª–æ–∫–∞ try & hellip; except:

–í—ã –º–æ–∂–µ—Ç–µ –∑–∞–∫–ª—é—á–∏—Ç—å –ª—é–±–æ–π –¥–æ–ø—É—Å—Ç–∏–º—ã–π –∫–æ–¥ Python –≤ –æ–ø–µ—Ä–∞—Ç–æ—Ä try –∏–ª–∏ except.

try & hellip; –∫—Ä–æ–º–µ –ø—Ä–∏–º–µ—Ä–∞ Python

< p> –í–æ—Ç –ø—Ä–∏–º–µ—Ä —Å–∏–Ω—Ç–∞–∫—Å–∏—Å–∞ –¥–ª—è –±–ª–æ–∫–æ–≤ try & hellip; except:

–í –ø—Ä–∏–≤–µ–¥–µ–Ω–Ω–æ–º –≤—ã—à–µ –ø—Ä–∏–º–µ—Ä–µ –º—ã –Ω–µ –æ–±—ä—è–≤–∏–ª–∏ –ø–µ—Ä–µ–º–µ–Ω–Ω—É—é Python ourVariable, –Ω–æ –º—ã –ø—ã—Ç–∞–µ–º—Å—è –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å –µ–≥–æ –≤ –Ω–∞—à–µ–º –±–ª–æ–∫–µ try.

–ï—Å–ª–∏ –±—ã –≤ –Ω–∞—à–µ–º –∫–æ–¥–µ –Ω–µ –±—ã–ª–æ –±–ª–æ–∫–æ–≤ try & hellip; except, –ø—Ä–æ–≥—Ä–∞–º–º–∞ –≤–µ—Ä–Ω—É–ª–∞ –±—ã —Å–æ–æ–±—â–µ–Ω–∏–µ –æ–± –æ—à–∏–±–∫–µ. –•–æ—Ç—è —Å–æ–æ–±—â–µ–Ω–∏–µ –æ–± –æ—à–∏–±–∫–µ –Ω–æ—Ä–º–∞–ª—å–Ω–æ –≤–æ –≤—Ä–µ–º—è –æ—Ç–ª–∞–¥–∫–∏, –æ–±—ã—á–Ω—ã–π –ø–æ–ª—å–∑–æ–≤–∞—Ç–µ–ª—å –º–æ–∂–µ—Ç –∑–∞–ø—É—Ç–∞—Ç—å—Å—è, –µ—Å–ª–∏ —É–≤–∏–¥–∏—Ç —Å–æ–æ–±—â–µ–Ω–∏–µ –æ–± –æ—à–∏–±–∫–µ.

–ü–æ—Å–∫–æ–ª—å–∫—É —É –Ω–∞—Å –µ—Å—Ç—å –±–ª–æ–∫–∏ try & hellip; except, –Ω–∞—à –∫–æ–¥ –∑–Ω–∞–µ—Ç, —á—Ç–æ –¥–µ–ª–∞—Ç—å –ø—Ä–∏ –æ–±–Ω–∞—Ä—É–∂–µ–Ω–∏–∏ –æ—à–∏–±–∫–∏.

–í–æ—Ç —Ä–µ–∑—É–ª—å—Ç–∞—Ç –Ω–∞—à–µ–≥–æ –∫–æ–¥–∞:

try & hellip; except –±–ª–æ–∫–∏ –ø–æ–∑–≤–æ–ª—è—é—Ç –∞–∫–∫—É—Ä–∞—Ç–Ω–æ –æ–±—Ä–∞–±–∞—Ç—ã–≤–∞—Ç—å –∏—Å–∫–ª—é—á–µ–Ω–∏—è. –í—ã —Ç–∞–∫–∂–µ –º–æ–∂–µ—Ç–µ —Ä–µ–∞–ª–∏–∑–æ–≤–∞—Ç—å —Ç–∞–∫—É—é ‚Äã‚Äã—Ñ—É–Ω–∫—Ü–∏—é, –∫–∞–∫ —Å–æ—Ö—Ä–∞–Ω–µ–Ω–∏–µ –∏—Å–∫–ª—é—á–µ–Ω–∏—è –≤ —Ñ–∞–π–ª –∂—É—Ä–Ω–∞–ª–∞, –∏—Å–ø–æ–ª—å–∑—É—è —Ç–∞–∫–æ–π –ø–∞–∫–µ—Ç, –∫–∞–∫ –º–æ–¥—É–ª—å –≤–µ–¥–µ–Ω–∏—è –∂—É—Ä–Ω–∞–ª–∞ Python . –≠—Ç–æ –ø–æ–∑–≤–æ–ª–∏—Ç –≤–∞–º –æ—Ç—Å–ª–µ–∂–∏–≤–∞—Ç—å –≤–æ–∑–Ω–∏–∫—à–∏–µ –∏—Å–∫–ª—é—á–µ–Ω–∏—è.

try & hellip; except Python: Multiple Except Statements

–í—ã –º–æ–∂–µ—Ç–µ –ø–æ–≤—Ç–æ—Ä—è—Ç—å –∏–Ω—Å—Ç—Ä—É–∫—Ü–∏–∏ except –¥–ª—è —Ä–∞–∑–Ω—ã—Ö —Ç–∏–ø–æ–≤ –æ—à–∏–±–æ–∫ –¥–ª—è –ø—Ä–æ–≤–µ—Ä–∫–∏ –Ω–∞ –º–Ω–æ–∂–µ—Å—Ç–≤–µ–Ω–Ω—ã–µ –∏—Å–∫–ª—é—á–µ–Ω–∏—è. –≠—Ç–æ –ø–æ–ª–µ–∑–Ω–æ, –µ—Å–ª–∏ –≤—ã –ø–æ–¥–æ–∑—Ä–µ–≤–∞–µ—Ç–µ, —á—Ç–æ –º–æ–∂–µ—Ç –≤–æ–∑–Ω–∏–∫–Ω—É—Ç—å –æ–¥–Ω–æ –∏–∑ –º–Ω–æ–≥–∏—Ö –∏—Å–∫–ª—é—á–µ–Ω–∏–π, –Ω–æ –Ω–µ —É–≤–µ—Ä–µ–Ω—ã, —Å –∫–∞–∫–∏–º –∏–∑ –Ω–∏—Ö –≤—ã —Å—Ç–æ–ª–∫–Ω–µ—Ç–µ—Å—å.

–í–æ—Ç –ø—Ä–∏–º–µ—Ä –±–ª–æ–∫–∞ try & hellip; >

 try: print (ourVariable) except NameError: print (’ourVariable is not defined’) except: print (’ Error return’) 

–í —ç—Ç–æ–º —Å–ª—É—á–∞–µ –Ω–∞—à –∫–æ–¥ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç ourVariable –Ω–µ –æ–ø—Ä–µ–¥–µ–ª–µ–Ω–æ, –ø–æ—Ç–æ–º—É —á—Ç–æ –Ω–∞—à –∫–æ–¥ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç NameError. –ú—ã –º–æ–≥–ª–∏ –±—ã –¥–æ–±–∞–≤–∏—Ç—å –±–æ–ª—å—à–µ –æ—à–∏–±–æ–∫, —Ç–∞–∫–∏—Ö –∫–∞–∫ ZeroDivisionError –∏–ª–∏ OSError, –≤ –∑–∞–≤–∏—Å–∏–º–æ—Å—Ç–∏ –æ—Ç –∫–æ–¥–∞, –∫–æ—Ç–æ—Ä—ã–π –º—ã —Ç–µ—Å—Ç–∏—Ä—É–µ–º.

–ù–∞–ø—Ä–∏–º–µ—Ä, –≤—ã –º–æ–∂–µ—Ç–µ –ø—Ä–æ–≤–µ—Ä–∏—Ç—å IOError –∏ FileNotFoundError, –µ—Å–ª–∏ —Ö–æ—Ç–∏—Ç–µ –æ—Ç–∫—Ä—ã—Ç—å —Ñ–∞–π–ª. –ü—Ä–æ–≤–µ—Ä–∫–∞ –Ω–µ—Å–∫–æ–ª—å–∫–∏—Ö –∏—Å–∫–ª—é—á–µ–Ω–∏–π –≥–∞—Ä–∞–Ω—Ç–∏—Ä—É–µ—Ç, —á—Ç–æ –≤–∞—à–∞ –ø—Ä–æ–≥—Ä–∞–º–º–∞ —Å–º–æ–∂–µ—Ç –ø—Ä–æ–¥–æ–ª–∂–∏—Ç—å —Ä–∞–±–æ—Ç—É, –¥–∞–∂–µ –µ—Å–ª–∏ –ø—Ä–∏ –æ—Ç–∫—Ä—ã—Ç–∏–∏ —Ñ–∞–π–ª–∞, –Ω–∞ –∫–æ—Ç–æ—Ä—ã–π –≤—ã —Å—Å—ã–ª–∞–µ—Ç–µ—Å—å, –ø—Ä–æ–∏–∑–æ—à–ª–∞ –æ—à–∏–±–∫–∞.

–ø–æ–ø—Ä–æ–±—É–π—Ç–µ & hellip; –∫—Ä–æ–º–µ Python: –Ω–∞–∫–æ–Ω–µ—Ü

–ù–æ —á—Ç–æ, –µ—Å–ª–∏ –º—ã —Ö–æ—Ç–∏–º, —á—Ç–æ–±—ã —Å–æ–æ–±—â–µ–Ω–∏–µ –ø–µ—á–∞—Ç–∞–ª–æ –æ–±–∞, –µ—Å–ª–∏ –æ—à–∏–±–∫–∞ i s –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç—Å—è, –∏ –µ—Å–ª–∏ –æ—à–∏–±–∫–∏ –Ω–µ –æ–±–Ω–∞—Ä—É–∂–µ–Ω—ã? –í–æ—Ç –≥–¥–µ –ø–æ—è–≤–ª—è–µ—Ç—Å—è –±–ª–æ–∫ finally. –ï—Å–ª–∏ –≤—ã –æ–ø—Ä–µ–¥–µ–ª–∏—Ç–µ –ø—Ä–µ–¥–ª–æ–∂–µ–Ω–∏–µ finally, –µ–≥–æ —Å–æ–¥–µ—Ä–∂–∏–º–æ–µ –±—É–¥–µ—Ç –≤—ã–ø–æ–ª–Ω—è—Ç—å—Å—è –Ω–µ–∑–∞–≤–∏—Å–∏–º–æ –æ—Ç —Ç–æ–≥–æ, –≤—ã–∑—ã–≤–∞–µ—Ç –ª–∏ –±–ª–æ–∫ try & hellip; except –æ—à–∏–±–∫—É.

–ë–ª–æ–∫ finally —è–≤–ª—è—é—Ç—Å—è –ø–æ–ª–µ–∑–Ω—ã–º –∏–Ω–¥–∏–∫–∞—Ç–æ—Ä–æ–º —Ç–æ–≥–æ, —á—Ç–æ –≤–∞—à –∫–æ–¥ –≤—ã–ø–æ–ª–Ω–∏–ª. –ü–æ—Å–∫–æ–ª—å–∫—É –æ–Ω–∏ –Ω–µ —Ä–∞–∑–ª–∏—á–∞—é—Ç, —É—Å–ø–µ—à–Ω–æ –ª–∏ –≤—ã–ø–æ–ª–Ω–µ–Ω –∫–æ–¥, –æ–Ω–∏ –Ω–µ —Ç–∞–∫ —à–∏—Ä–æ–∫–æ –∏—Å–ø–æ–ª—å–∑—É—é—Ç—Å—è.

–í–æ—Ç –ø—Ä–∏–º–µ—Ä:

–ù–∞—à–∞ –ø—Ä–æ–≥—Ä–∞–º–º–∞ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç —Å–ª–µ–¥—É—é—â–µ–µ:

"–ö–∞—Ä—å–µ—Ä–Ω–∞—è –∫–∞—Ä–º–∞ –≤–æ—à–ª–∞ –≤ –º–æ—é –∂–∏–∑–Ω—å, –∫–æ–≥–¥–∞ —è –±–æ–ª—å—à–µ –≤—Å–µ–≥–æ –≤ –Ω–µ–π –Ω—É–∂–¥–∞–ª–∞—Å—å, –∏ –±—ã—Å—Ç—Ä–æ –ø–æ–º–æ–≥–ª–∞ –º–Ω–µ –ø—Ä–æ–π—Ç–∏ –∫—É—Ä—Å –æ–±—É—á–µ–Ω–∏—è. –ß–µ—Ä–µ–∑ –¥–≤–∞ –º–µ—Å—è—Ü–∞ –ø–æ—Å–ª–µ –æ–∫–æ–Ω—á–∞–Ω–∏—è —É—á–µ–±—ã —è –Ω–∞—à–µ–ª —Ä–∞–±–æ—Ç—É —Å–≤–æ–µ–π –º–µ—á—Ç—ã, –∫–æ—Ç–æ—Ä–∞—è —Å–æ–æ—Ç–≤–µ—Ç—Å—Ç–≤–æ–≤–∞–ª–∞ –º–æ–∏–º —Ü–µ–Ω–Ω–æ—Å—Ç—è–º –∏ —Ü–µ–ª–∏ –≤ –∂–∏–∑–Ω–∏! "

–í–µ–Ω–µ—Ä–∞, –∏–Ω–∂–µ–Ω–µ—Ä-–ø—Ä–æ–≥—Ä–∞–º–º–∏—Å—Ç Rockbot

–ö–æ–¥ –≤ –±–ª–æ–∫–µ except –≤—ã–ø–æ–ª–Ω—è–µ—Ç—Å—è –ø–æ—Ç–æ–º—É —á—Ç–æ –≤ –Ω–∞—à–µ–º –∫–æ–¥–µ –æ–±–Ω–∞—Ä—É–∂–µ–Ω–æ –∏—Å–∫–ª—é—á–µ–Ω–∏–µ (–Ω–∞—à–∞ –ø–µ—Ä–µ–º–µ–Ω–Ω–∞—è –Ω–µ –æ–ø—Ä–µ–¥–µ–ª–µ–Ω–∞). –ö–æ–¥ –≤ –ø—Ä–µ–¥–ª–æ–∂–µ–Ω–∏–∏ finally —Ç–∞–∫–∂–µ –≤—ã–ø–æ–ª–Ω—è–µ—Ç—Å—è, –ø–æ—Ç–æ–º—É —á—Ç–æ –Ω–∞—à –∫–æ–¥ –∑–∞–≤–µ—Ä—à–µ–Ω.

try & hellip; except Python: Else

–ò—Å–ø–æ–ª—å–∑—É—è –ø—Ä–µ–¥–ª–æ–∂–µ–Ω–∏–µ else, –≤—ã –º–æ–∂–µ—Ç–µ –æ–ø—Ä–µ–¥–µ–ª–∏—Ç—å –∫–æ–¥, –∫–æ—Ç–æ—Ä—ã–π –±—É–¥–µ—Ç –∑–∞–ø—É—Å–∫–∞—Ç—å—Å—è –≤ —Å–ª—É—á–∞–µ, –µ—Å–ª–∏ –Ω–µ –≤–æ–∑–Ω–∏–∫–Ω—É—Ç –∏—Å–∫–ª—é—á–µ–Ω–∏—è. –≠—Ç–æ –º–æ–∂–µ—Ç –±—ã—Ç—å –∏—Å–ø–æ–ª—å–∑–æ–≤–∞–Ω–æ, –Ω–∞–ø—Ä–∏–º–µ—Ä, –¥–ª—è –∏–Ω—Ñ–æ—Ä–º–∏—Ä–æ–≤–∞–Ω–∏—è –ø–æ–ª—å–∑–æ–≤–∞—Ç–µ–ª—è –æ–± —É—Å–ø–µ—à–Ω–æ–º –≤—ã–ø–æ–ª–Ω–µ–Ω–∏–∏ –ø—Ä–æ–≥—Ä–∞–º–º—ã.

–ü—Ä–µ–¥—Å—Ç–∞–≤—å—Ç–µ, —á—Ç–æ –≤—ã —Å–æ–∑–¥–∞–µ—Ç–µ —Å–∏—Å—Ç–µ–º—É —Ä–µ–≥–∏—Å—Ç—Ä–∞—Ü–∏–∏ –¥–ª—è –∏–≥—Ä—ã. –í—ã –º–æ–∂–µ—Ç–µ –≤–∫–ª—é—á–∏—Ç—å –±–ª–æ–∫ try & hellip; except & hellip; else, —á—Ç–æ–±—ã –ø—Ä–æ–≤–µ—Ä–∏—Ç—å, —è–≤–ª—è–µ—Ç—Å—è –ª–∏ –∏–º—è –ø–æ–ª—å–∑–æ–≤–∞—Ç–µ–ª—è –∏–ª–∏ –∞–¥—Ä–µ—Å —ç–ª–µ–∫—Ç—Ä–æ–Ω–Ω–æ–π –ø–æ—á—Ç—ã, –≤—ã–±—Ä–∞–Ω–Ω—ã–µ –ø–æ–ª—å–∑–æ–≤–∞—Ç–µ–ª–µ–º, –¥–µ–π—Å—Ç–≤–∏—Ç–µ–ª—å–Ω—ã–º. –ï—Å–ª–∏ —ç—Ç–æ –Ω–µ —Ç–∞–∫, –±—É–¥–µ—Ç –≤—ã–ø–æ–ª–Ω–µ–Ω–æ –ø—Ä–µ–¥–ª–æ–∂–µ–Ω–∏–µ except. –ï—Å–ª–∏ –∏–º—è –ø–æ–ª—å–∑–æ–≤–∞—Ç–µ–ª—è –∏–ª–∏ –∞–¥—Ä–µ—Å —ç–ª–µ–∫—Ç—Ä–æ–Ω–Ω–æ–π –ø–æ—á—Ç—ã –¥–µ–π—Å—Ç–≤–∏—Ç–µ–ª—å–Ω—ã, –±–ª–æ–∫ else –º–æ–∂–µ—Ç –±—ã—Ç—å –∑–∞–ø—É—â–µ–Ω.

–í–æ—Ç –ø—Ä–∏–º–µ—Ä:

–ù–∞—à –∫–æ–¥ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç —Å–ª–µ–¥—É—é—â–µ–µ:

–ù–∞—à–∞ –ø—Ä–æ–≥—Ä–∞–º–º–∞ Python –Ω–µ –æ–±–Ω–∞—Ä—É–∂–∏–≤–∞–µ—Ç –∏—Å–∫–ª—é—á–µ–Ω–∏–π. –í —Ä–µ–∑—É–ª—å—Ç–∞—Ç–µ –≤—ã–ø–æ–ª–Ω—è–µ—Ç—Å—è –∫–æ–¥ –≤ –æ–ø–µ—Ä–∞—Ç–æ—Ä–µ else. –û–ø–µ—Ä–∞—Ç–æ—Ä else –≤—ã–≤–æ–¥–∏—Ç —Å–æ–æ–±—â–µ–Ω–∏–µ –∑–∞—è–≤–ª—è—è, —á—Ç–æ –Ω–µ—Ç –ø—Ä–æ–±–ª–µ–º —Å –Ω–∞—à–∏–º c ode.

–ü—Ä–æ—Å–º–æ—Ç—Ä–∏—Ç–µ Repl.it –∏–∑ —ç—Ç–æ–≥–æ —Ä—É–∫–æ–≤–æ–¥—Å—Ç–≤–∞: