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

–§—É–Ω–∫—Ü–∏—è isinstance () –≤ Python –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç –∑–Ω–∞—á–µ–Ω–∏–µ true –∏–ª–∏ false, –µ—Å–ª–∏ –ø–µ—Ä–µ–º–µ–Ω–Ω–∞—è —Å–æ–æ—Ç–≤–µ—Ç—Å—Ç–≤—É–µ—Ç —É–∫–∞–∑–∞–Ω–Ω–æ–º—É —Ç–∏–ø—É –¥–∞–Ω–Ω—ã—Ö. –°–∏–Ω—Ç–∞–∫—Å–∏—Å –¥–ª—è isinstance () –≤ Python: isinstance (variable_to_check, data_type) .

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

–í–æ—Ç –≥–¥–µ isinstance ( ) –º–æ–∂–µ—Ç –±—ã—Ç—å –ø–æ–ª–µ–∑–Ω–æ–π. isinstance () - —ç—Ç–æ –≤—Å—Ç—Ä–æ–µ–Ω–Ω—ã–π –º–µ—Ç–æ–¥ Python, –∫–æ—Ç–æ—Ä—ã–π –ø–æ–∑–≤–æ–ª—è–µ—Ç –≤–∞–º –ø—Ä–æ–≤–µ—Ä—è—Ç—å —Ç–∏–ø –¥–∞–Ω–Ω—ã—Ö –æ–ø—Ä–µ–¥–µ–ª–µ–Ω–Ω–æ–≥–æ –∑–Ω–∞—á–µ–Ω–∏—è. –ù–∞–ø—Ä–∏–º–µ—Ä, –≤—ã –º–æ–∂–µ—Ç–µ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å isinstance (), —á—Ç–æ–±—ã –ø—Ä–æ–≤–µ—Ä–∏—Ç—å, —è–≤–ª—è–µ—Ç—Å—è –ª–∏ –∑–Ω–∞—á–µ–Ω–∏–µ —Å—Ç—Ä–æ–∫–æ–π –∏–ª–∏ —Å–ø–∏—Å–∫–æ–º.

–í —ç—Ç–æ–º —Ä—É–∫–æ–≤–æ–¥—Å—Ç–≤–µ –≤—ã —É–∑–Ω–∞–µ—Ç–µ, –∫–∞–∫ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å isinstance ( ) –≤ Python –∏ –ø—Ä–µ–¥–æ—Å—Ç–∞–≤–∏—Ç –Ω–µ—Å–∫–æ–ª—å–∫–æ –ø—Ä–∏–º–µ—Ä–æ–≤, –∫–æ—Ç–æ—Ä—ã–µ –ø–æ–º–æ–≥—É—Ç –≤–∞–º –ª—É—á—à–µ –ø–æ–Ω—è—Ç—å –µ–≥–æ.

–û–±–∑–æ—Ä Python - —ç—Ç–æ —ç–∫–∑–µ–º–ø–ª—è—Ä

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

–ü–æ—ç—Ç–æ–º—É –≤–∞–∂–Ω–æ, —á—Ç–æ–±—ã –≤—ã —Ä–∞–±–æ—Ç–∞–ª–∏ —Å –ø—Ä–∞–≤–∏–ª—å–Ω—ã–º–∏ —Ç–∏–ø–∞–º–∏ –¥–∞–Ω–Ω—ã—Ö –≤ —Å–≤–æ–µ–π –ø—Ä–æ–≥—Ä–∞–º–º–µ. –í—ã –º–æ–∂–µ—Ç–µ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å isinstance –≤ Python, —á—Ç–æ–±—ã —É–±–µ–¥–∏—Ç—å—Å—è, —á—Ç–æ –¥–∞–Ω–Ω—ã–µ, —Å –∫–æ—Ç–æ—Ä—ã–º–∏ –≤—ã —Ä–∞–±–æ—Ç–∞–µ—Ç–µ, —Ö—Ä–∞–Ω—è—Ç—Å—è –∫–∞–∫ —Å–æ–æ—Ç–≤–µ—Ç—Å—Ç–≤—É—é—â–∏–π —Ç–∏–ø –¥–∞–Ω–Ω—ã—Ö. –ü—Ä–∏ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞–Ω–∏–∏ Python –ø—Ä–æ–≤–µ—Ä—è–π—Ç–µ —Ç–∏–ø—ã –¥–∞–Ω–Ω—ã—Ö –ø–æ –º–µ—Ä–µ –Ω–µ–æ–±—Ö–æ–¥–∏–º–æ—Å—Ç–∏.

isinstance () - —ç—Ç–æ –≤—Å—Ç—Ä–æ–µ–Ω–Ω–∞—è –≤ Python —Ñ—É–Ω–∫—Ü–∏—è, –∫–æ—Ç–æ—Ä–∞—è –ø—Ä–æ–≤–µ—Ä—è–µ—Ç, —Å–æ—Ö—Ä–∞–Ω–µ–Ω–æ –ª–∏ –∑–Ω–∞—á–µ–Ω–∏–µ –∫–∞–∫ –æ–ø—Ä–µ–¥–µ–ª–µ–Ω–Ω—ã–π —Ç–∏–ø –¥–∞–Ω–Ω—ã—Ö. –í –æ—Ç–ª–∏—á–∏–µ –æ—Ç –º–µ—Ç–æ–¥–∞ type (), –∫–æ—Ç–æ—Ä—ã–π –æ–±—Å—É–∂–¥–∞–µ—Ç—Å—è –¥–∞–ª–µ–µ –≤ —ç—Ç–æ–π —Å—Ç–∞—Ç—å–µ, –º–µ—Ç–æ–¥ isinstance () –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç —Ç–æ–ª—å–∫–æ True –∏–ª–∏ False, –≤ –∑–∞–≤–∏—Å–∏–º–æ—Å—Ç–∏ –æ—Ç —Ç–æ–≥–æ, —Ö—Ä–∞–Ω–∏—Ç—Å—è –ª–∏ –ø—Ä–æ–≤–µ—Ä—è–µ–º–æ–µ –∑–Ω–∞—á–µ–Ω–∏–µ –≤ –≤–∏–¥–µ —É–∫–∞–∑–∞–Ω–Ω–æ–≥–æ —Ç–∏–ø–∞ –¥–∞–Ω–Ω—ã—Ö –∏–ª–∏ —Ç–∏–ø–æ–≤.

–°–∏–Ω—Ç–∞–∫—Å–∏—Å –¥–ª—è isinstance () —Å–ª–µ–¥—É—é—â–∏–π:

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

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

isinstance ( ) –ø—Ä–∏–Ω–∏–º–∞–µ—Ç –¥–≤–∞ –ø–∞—Ä–∞–º–µ—Ç—Ä–∞, –æ–±–∞ –∏–∑ –∫–æ—Ç–æ—Ä—ã—Ö —è–≤–ª—è—é—Ç—Å—è –æ–±—è–∑–∞—Ç–µ–ª—å–Ω—ã–º–∏:

  • object : –æ–±—ä–µ–∫—Ç, —Ç–∏–ø –¥–∞–Ω–Ω—ã—Ö –∫–æ—Ç–æ—Ä–æ–≥–æ –≤—ã —Ö–æ—Ç–∏—Ç–µ –ø—Ä–æ–≤–µ—Ä–∏—Ç—å.
  • data_types : —Ö–æ—Ç—è –±—ã –æ–¥–∏–Ω –∏–∑ –≤–æ–∑–º–æ–∂–Ω—ã—Ö —Ç–∏–ø–æ–≤ –¥–∞–Ω–Ω—ã—Ö –æ–±—ä–µ–∫—Ç–∞. & nbsp;

–ó–∞—Ç–µ–º –º–µ—Ç–æ–¥ isinstance () —Å—Ä–∞–≤–Ω–∏–≤–∞–µ—Ç –æ–±—ä–µ–∫—Ç —Å —É–∫–∞–∑–∞–Ω–Ω—ã–º–∏ –≤–∞–º–∏ —Ç–∏–ø–∞–º–∏ –¥–∞–Ω–Ω—ã—Ö. –ï—Å–ª–∏ –≤—ã —Ö–æ—Ç–∏—Ç–µ —Å—Ä–∞–≤–Ω–∏—Ç—å –æ–±—ä–µ–∫—Ç —Å –¥–≤—É–º—è –∏–ª–∏ –±–æ–ª–µ–µ –¥–∞–Ω–Ω—ã–º–∏ —Ç–∏–ø—ã, –≤–∞–º –Ω–µ–æ–±—Ö–æ–¥–∏–º–æ —É–∫–∞–∑–∞—Ç—å –∫–æ—Ä—Ç–µ–∂ –≤ –∫–∞—á–µ—Å—Ç–≤–µ –ø–∞—Ä–∞–º–µ—Ç—Ä–∞ data_types.

–í –æ—Ç–≤–µ—Ç –≤–∞—à –∫–æ–¥ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç True –∏–ª–∏ False. –ö–æ–¥ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç True, –µ—Å–ª–∏ –æ–±—ä–µ–∫—Ç –ø—Ä–∏–Ω–∞–¥–ª–µ–∂–∏—Ç –∫ —É–∫–∞–∑–∞–Ω–Ω–æ–º—É –≤–∞–º–∏ —Ç–∏–ø—É –¥–∞–Ω–Ω—ã—Ö (–∏–ª–∏ –æ–¥–Ω–æ–º—É –∏–∑ —Ç–∏–ø–æ–≤ –¥–∞–Ω–Ω—ã—Ö), –∏ False, –µ—Å–ª–∏ –Ω–µ—Ç.

–ü–æ —Å—É—Ç–∏, –∫–æ–≥–¥–∞ –≤—ã –∏—Å–ø–æ–ª—å–∑—É–µ—Ç–µ isinstance –≤ Python, –≤—ã –ø—Ä–µ–¥—Å—Ç–∞–≤–ª—è–µ—Ç–µ —Å–≤–æ–π –∫–æ–¥ —Å –ø–æ–º–æ—â—å—é –æ–ø–µ—Ä–∞—Ç–æ—Ä–∞ –∑–∞–ø–æ–ª–Ω–µ–Ω–∏—è –ø—É—Å—Ç–æ–≥–æ –ø–æ–ª—è –∏ –ø–æ –∫—Ä–∞–π–Ω–µ–π –º–µ—Ä–µ –æ–¥–Ω–æ–≥–æ –≤–∞—Ä–∏–∞–Ω—Ç–∞ –æ—Ç–≤–µ—Ç–∞. –í–∞—à–µ —É—Ç–≤–µ—Ä–∂–¥–µ–Ω–∏–µ: –≠—Ç–æ—Ç –æ–±—ä–µ–∫—Ç —è–≤–ª—è–µ—Ç—Å—è (—Ç–∏–ø–æ–º –¥–∞–Ω–Ω—ã—Ö). –£–∫–∞–∑–∞–Ω–∏–µ —Ç–∏–ø–∞ –¥–∞–Ω–Ω—ã—Ö –∑–∞–≤–µ—Ä—à–∞–µ—Ç —ç—Ç–æ—Ç –æ–ø–µ—Ä–∞—Ç–æ—Ä. –î–≤–∞ –ø—Ä–∏–º–µ—Ä–∞: & nbsp;

  • 12 - —ç—Ç–æ —á–∏—Å–ª–æ.
  • books - —ç—Ç–æ –Ω–æ–º–µ—Ä.

–Ø –í –æ—Ç–≤–µ—Ç –≤–∞—à –∫–æ–¥ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç True –∏–ª–∏ False.

–ü—Ä–∏–º–µ—Ä—ã —ç–∫–∑–µ–º–ø–ª—è—Ä–æ–≤ Python

–î–∞–≤–∞–π—Ç–µ —Ä–∞—Å—Å–º–æ—Ç—Ä–∏–º –¥–≤–∞ –ø—Ä–∏–º–µ—Ä–∞, —á—Ç–æ–±—ã –ø–æ–∫–∞–∑–∞—Ç—å –∫–∞–∫ –º–æ–∂–Ω–æ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å –≤ –∫–æ–¥–µ –º–µ—Ç–æ–¥ isinstance (). –°–∫–∞–∂–µ–º, —É –Ω–∞—Å –µ—Å—Ç—å –∑–Ω–∞—á–µ–Ω–∏–µ, –∏ –º—ã —Ö–æ—Ç–∏–º —É–±–µ–¥–∏—Ç—å—Å—è, —á—Ç–æ –æ–Ω–æ —è–≤–ª—è–µ—Ç—Å—è —Å—Ç—Ä–æ–∫–æ–π. –î–ª—è —ç—Ç–æ–≥–æ –º—ã –º–æ–≥–ª–∏ –±—ã –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å isinstance (). –í–æ—Ç –∫–æ–¥, –∫–æ—Ç–æ—Ä—ã–π –º—ã –º–æ–≥–ª–∏ –±—ã –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å:

–ù–∞—à –∫–æ–¥ –≤—ã–ø–æ–ª–Ω—è–µ—Ç –ø—Ä–æ–≤–µ—Ä–∫—É —Ç–∏–ø–∞, –∞ –∑–∞—Ç–µ–º –Ω–∞—à–∞ —Ñ—É–Ω–∫—Ü–∏—è –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç: True. & nbsp;

–ü–æ—Å–∫–æ–ª—å–∫—É String –Ω–∞ —Å–∞–º–æ–º –¥–µ–ª–µ —Å—Ç—Ä–æ–∫—É (str - —ç—Ç–æ —Ç–æ, –∫–∞–∫ –≤—ã —Å—Å—ã–ª–∞–µ—Ç–µ—Å—å –Ω–∞ —Ç–∏–ø –¥–∞–Ω–Ω—ã—Ö string –≤ Python), –Ω–∞—à–∞ –ø—Ä–æ–≥—Ä–∞–º–º–∞ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç True.

–¢–µ–ø–µ—Ä—å –º—ã —Ä–∞—Å—Å–º–æ—Ç—Ä–∏–º –±–æ–ª–µ–µ –ø–æ–¥—Ä–æ–±–Ω—ã–π –ø—Ä–∏–º–µ—Ä.

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

–ß—Ç–æ–±—ã –ø—Ä–æ–≤–µ—Ä–∏—Ç—å, —è–≤–ª—è–µ—Ç—Å—è –ª–∏ –ø–æ–ª—É—á–µ–Ω–Ω—ã–π –Ω–∞–º–∏ –æ—Ç–≤–µ—Ç –æ—Ç –∏–≥—Ä–æ–∫–∞ —á–∏—Å–ª–æ–º, –º—ã –º–æ–≥–ª–∏ –±—ã –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å —ç—Ç–æ—Ç –∫–æ–¥ :

–ù–∞—à –∫–æ–¥ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç: False.

–î–∞–≤–∞–π—Ç–µ —Ä–∞–∑–±–µ—Ä–µ–º –Ω–∞—à—É –ø—Ä–æ–≥—Ä–∞–º–º—É. –í –ø–µ—Ä–≤–æ–π —Å—Ç—Ä–æ–∫–µ –º—ã –≤—ã—á–∏—Å–ª—è–µ–º –æ—Ç–≤–µ—Ç –Ω–∞ –º–∞—Ç–µ–º–∞—Ç–∏—á–µ—Å–∫—É—é –∑–∞–¥–∞—á—É, –∫–æ—Ç–æ—Ä—É—é –º—ã –ø–æ—Å—Ç–∞–≤–∏–ª–∏ –ø–µ—Ä–µ–¥ –∏–≥—Ä–æ–∫–æ–º. –í –¥–∞–Ω–Ω–æ–º —Å–ª—É—á–∞–µ –º–∞—Ç–µ–º–∞—Ç–∏—á–µ—Å–∫–∞—è –∑–∞–¥–∞—á–∞ –∑–∞–∫–ª—é—á–∞–ª–∞—Å—å –≤ —Å–ª–µ–¥—É—é—â–µ–º: –ß—Ç–æ —Ç–∞–∫–æ–µ 5 x 8?, –ø–æ—ç—Ç–æ–º—É –º—ã –≤–≤–æ–¥–∏–º answer = 5 * 8 –¥–ª—è –ø–µ—Ä–≤–æ–π —Å—Ç—Ä–æ–∫–∏ –Ω–∞—à–µ–≥–æ –∫–æ–¥–∞. & Nbsp;

–ó–∞—Ç–µ–º –º—ã –∏—Å–ø–æ–ª—å–∑—É–µ–º –º–µ—Ç–æ–¥ input () –¥–ª—è –ø–æ–ª—É—á–µ–Ω–∏—è –æ—Ç–≤–µ—Ç–∞ –æ—Ç –ø–æ–ª—å–∑–æ–≤–∞—Ç–µ–ª—è.

–í –ø–æ—Å–ª–µ–¥–Ω–µ–π —Å—Ç—Ä–æ–∫–µ –Ω–∞—à–µ–≥–æ –∫–æ–¥–∞ , –º—ã –∏—Å–ø–æ–ª—å–∑—É–µ–º isinstance (), —á—Ç–æ–±—ã –ø—Ä–æ–≤–µ—Ä–∏—Ç—å, —è–≤–ª—è–µ—Ç—Å—è –ª–∏ –æ—Ç–≤–µ—Ç –Ω–∞—à–µ–≥–æ –ø–æ–ª—å–∑–æ–≤–∞—Ç–µ–ª—è (—Ö—Ä–∞–Ω—è—â–∏–π—Å—è –≤ user_answer) —Ü–µ–ª—ã–º —á–∏—Å–ª–æ–º –∏–ª–∏ —á–∏—Å–ª–æ–º —Å –ø–ª–∞–≤–∞—é—â–µ–π –∑–∞–ø—è—Ç–æ–π, –∫–æ—Ç–æ—Ä—ã–µ —è–≤–ª—è—é—Ç—Å—è –¥–≤—É–º—è —Ç–∏–ø–∞–º–∏ –¥–∞–Ω–Ω—ã—Ö, –∏—Å–ø–æ–ª—å–∑—É–µ–º—ã–º–∏ –¥–ª—è –ø—Ä–µ–¥—Å—Ç–∞–≤–ª–µ–Ω–∏—è —á–∏—Å–µ–ª –≤ Python. –ú—ã –¥–µ–ª–∞–µ–º —ç—Ç–æ, —Å–æ–∑–¥–∞–≤–∞—è –∫–æ—Ä—Ç–µ–∂, –≤ –∫–æ—Ç–æ—Ä–æ–º —Ö—Ä–∞–Ω—è—Ç—Å—è —Ç–∏–ø—ã –¥–∞–Ω–Ω—ã—Ö, –ø–æ –∫–æ—Ç–æ—Ä—ã–º –º—ã —Ö–æ—Ç–∏–º –ø—Ä–æ–≤–µ—Ä–∏—Ç—å –Ω–∞—à–µ –∑–Ω–∞—á–µ–Ω–∏–µ. –í –Ω–∞—à–µ–º –∫–æ–¥–µ —ç—Ç–æ—Ç –∫–æ—Ä—Ç–µ–∂: (int, float).

–ù–∞—à –∫–æ–¥ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç False, –∫–æ—Ç–æ—Ä—ã–π —Å–æ–æ–±—â–∞–µ—Ç –Ω–∞–º, —á—Ç–æ –æ—Ç–≤–µ—Ç –ø–æ–ª—å–∑–æ–≤–∞—Ç–µ–ª—è –Ω–µ —è–≤–ª—è–µ—Ç—Å—è –Ω–∏ —Ü–µ–ª—ã–º —á–∏—Å–ª–æ–º (int), –Ω–∏ —á–∏—Å–ª–æ–º —Å –ø–ª–∞–≤–∞—é—â–µ–π —Ç–æ—á–∫–æ–π. & nbsp;

–¢–µ–ø–µ—Ä—å, –∫–æ–≥–¥–∞ –º—ã –∑–Ω–∞–µ–º, —á—Ç–æ –Ω–∞—à –æ–±—ä–µ–∫—Ç –Ω–µ —è–≤–ª—è–µ—Ç—Å—è —ç–∫–∑–µ–º–ø–ª—è—Ä–æ–º int –∏–ª–∏ float, –º—ã –º–æ–∂–µ–º –Ω–∞—á–∞—Ç—å –¥–∏–∞–≥–Ω–æ—Å—Ç–∏–∫—É –ø—Ä–æ–±–ª–µ–º—ã. –ù–∞—à –∫–æ–¥ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç False, –ø–æ—Ç–æ–º—É —á—Ç–æ input () –¥–∞–µ—Ç –Ω–∞–º —Å—Ç—Ä–æ–∫—É –ø–æ —É–º–æ–ª—á–∞–Ω–∏—é, –¥–∞–∂–µ –µ—Å–ª–∏ –ø–æ–ª—å–∑–æ–≤–∞—Ç–µ–ª—å –≤–≤–æ–¥–∏—Ç –Ω—é –º–±–µ—Ä. –ò—Ç–∞–∫, —á—Ç–æ–±—ã –Ω–∞—à –∫–æ–¥ —Ä–∞–±–æ—Ç–∞–ª, –Ω–∞–º –Ω—É–∂–Ω–æ –ø—Ä–µ–æ–±—Ä–∞–∑–æ–≤–∞—Ç—å —Ä–µ–∑—É–ª—å—Ç–∞—Ç –Ω–∞—à–µ–≥–æ –º–µ—Ç–æ–¥–∞ input () –≤ —Ü–µ–ª–æ–µ —á–∏—Å–ª–æ. –≠—Ç–æ –º–æ–∂–Ω–æ —Å–¥–µ–ª–∞—Ç—å —Å –ø–æ–º–æ—â—å—é —Å–ª–µ–¥—É—é—â–µ–≥–æ –∫–æ–¥–∞:

–¢–µ–ø–µ—Ä—å, –∫–æ–≥–¥–∞ –º—ã –∑–∞–ø—É—Å–∫–∞–µ–º –Ω–∞—à –∫–æ–¥, –º—ã –ø–æ–ª—É—á–∞–µ–º: True . & nbsp;

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

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

–ï–¥–∏–Ω—Å—Ç–≤–µ–Ω–Ω–æ–µ –æ—Ç–ª–∏—á–∏–µ —ç—Ç–æ–≥–æ –ø—Ä–∏–º–µ—Ä–∞ –æ—Ç –ø—Ä–µ–¥—ã–¥—É—â–µ–≥–æ –∑–∞–∫–ª—é—á–∞–µ—Ç—Å—è –≤ —Ç–æ–º, —á—Ç–æ –≤ —ç—Ç–æ–º –∫–æ–¥–µ –Ω–∞ –≤ —Å—Ç—Ä–æ–∫–µ user_answer –º—ã –ø—Ä–µ–æ–±—Ä–∞–∑—É–µ–º —Ä–µ–∑—É–ª—å—Ç–∞—Ç –Ω–∞—à–µ–≥–æ –º–µ—Ç–æ–¥–∞ input () –≤ —Ü–µ–ª–æ–µ —á–∏—Å–ª–æ —Å –ø–æ–º–æ—â—å—é int (). –ü–æ—ç—Ç–æ–º—É –ø—Ä–æ–≥—Ä–∞–º–º–∞ —Ä–µ–≥–∏—Å—Ç—Ä–∏—Ä—É–µ—Ç –≤–≤–æ–¥ –∫–∞–∫ —Ü–µ–ª–æ–µ —á–∏—Å–ª–æ, –∞ –Ω–µ —Å—Ç—Ä–æ–∫—É. –ò—Ç–∞–∫, –∫–æ–≥–¥–∞ –º—ã –ø—Ä–æ–≤–µ—Ä—è–µ–º —Ç–∏–ø –¥–∞–Ω–Ω—ã—Ö —ç—Ç–æ–≥–æ –∑–Ω–∞—á–µ–Ω–∏—è —Å –ø–æ–º–æ—â—å—é –º–µ—Ç–æ–¥–∞ isinstance (), –Ω–∞—à–∞ –ø—Ä–æ–≥—Ä–∞–º–º–∞ –ø—Ä–æ–≤–µ—Ä—è–µ—Ç, —è–≤–ª—è–µ—Ç—Å—è –ª–∏ –∑–Ω–∞—á–µ–Ω–∏–µ —Ü–µ–ª—ã–º –∏–ª–∏ –ø–ª–∞–≤–∞—é—â–∏–º.

–í –ø—Ä–∏–≤–µ–¥–µ–Ω–Ω–æ–º –≤—ã—à–µ –ø—Ä–∏–º–µ—Ä–µ , –º—ã –ø—Ä–æ–≤–µ—Ä–∏–ª–∏, —Å–æ–¥–µ—Ä–∂–∏—Ç –ª–∏ –æ–±—ä–µ–∫—Ç –æ–ø—Ä–µ–¥–µ–ª–µ–Ω–Ω—ã–π –≤—Å—Ç—Ä–æ–µ–Ω–Ω—ã–π —Ç–∏–ø –¥–∞–Ω–Ω—ã—Ö. –ú–µ—Ç–æ–¥ isinstance () —Ç–∞–∫–∂–µ –º–æ–∂–Ω–æ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å –¥–ª—è —Å—Ä–∞–≤–Ω–µ–Ω–∏—è –æ–±—ä–µ–∫—Ç–∞ —Å –æ–ø—Ä–µ–¥–µ–ª–µ–Ω–Ω—ã–º –∫–ª–∞—Å—Å–æ–º.

type vs. isinstance

–ï—Å–ª–∏ –≤–∞–º –∫–æ–≥–¥–∞-–ª–∏–±–æ –ø—Ä–∏—Ö–æ–¥–∏–ª–æ—Å—å –ø—Ä–æ–≤–µ—Ä—è—Ç—å —Ç–∏–ø –∑–Ω–∞—á–µ–Ω–∏—è –≤ Python, –≤—ã, –≤–æ–∑–º–æ–∂–Ω–æ, –≤—Å—Ç—Ä–µ—á–∞–ª–∏ type () –º–µ—Ç–æ–¥. type () - —ç—Ç–æ –≤—Å—Ç—Ä–æ–µ–Ω–Ω–∞—è —Ñ—É–Ω–∫—Ü–∏—è Python, –∫–æ—Ç–æ—Ä—É—é –º–æ–∂–Ω–æ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å –¥–ª—è –æ–ø—Ä–µ–¥–µ–ª–µ–Ω–∏—è —Ç–∏–ø–∞ –ø–µ—Ä–µ–º–µ–Ω–Ω–æ–π –∏–ª–∏ –∑–Ω–∞—á–µ–Ω–∏—è. –í–æ—Ç —Å–∏–Ω—Ç–∞–∫—Å–∏—Å –¥–ª—è –º–µ—Ç–æ–¥–∞ —Ç–∏–ø–∞ Python:

–ù–∞–ø—Ä–∏–º–µ—Ä, –¥–æ–ø—É—Å—Ç–∏–º, —É –≤–∞—Å –µ—Å—Ç—å –Ω–æ–º–µ—Ä –∏ –≤—ã —Ö–æ—Ç–∏—Ç–µ –ø—Ä–æ–≤–µ—Ä–∏—Ç—å, –∫–∞–∫–æ–π —Ç–∏–ø –¥–∞–Ω–Ω—ã—Ö –æ–Ω –∑–∞–∫–æ–¥–∏—Ä–æ–≤–∞–Ω. –≠—Ç–æ –º–æ–∂–Ω–æ —Å–¥–µ–ª–∞—Ç—å —Å –ø–æ–º–æ—â—å—é —Å–ª–µ–¥—É—é—â–µ–≥–æ –∫–æ–¥–∞:

–ù–∞—à –∫–æ–¥ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç:

–ö–∞–∫ –≤–∏–¥–∏—Ç–µ, –Ω–∞—à–∞ –ø—Ä–æ–≥—Ä–∞–º–º–∞ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç —Ç–∏–ø –Ω–∞—à–µ–≥–æ dat –∞. –û–Ω —Å–æ–æ–±—â–∞–µ—Ç –Ω–∞–º, —á—Ç–æ —ç—Ç–∏ –¥–∞–Ω–Ω—ã–µ —Ö—Ä–∞–Ω—è—Ç—Å—è –∫–∞–∫ —Ü–µ–ª–æ–µ —á–∏—Å–ª–æ.

–ï—Å—Ç—å –æ–¥–Ω–æ –±–æ–ª—å—à–æ–µ —Ä–∞–∑–ª–∏—á–∏–µ –º–µ–∂–¥—É —Ñ—É–Ω–∫—Ü–∏—è–º–∏ type () –∏ isinstance (), –∫–æ—Ç–æ—Ä–æ–µ –¥–µ–ª–∞–µ—Ç –æ–¥–∏–Ω –±–æ–ª–µ–µ –ø–æ–¥—Ö–æ–¥—è—â–∏–π –¥–ª—è –∏—Å–ø–æ–ª—å–∑–æ–≤–∞–Ω–∏—è, —á–µ–º –¥—Ä—É–≥–æ–π –ø—Ä–∏ –æ–ø—Ä–µ–¥–µ–ª–µ–Ω–Ω—ã—Ö –æ–±—Å—Ç–æ—è—Ç–µ–ª—å—Å—Ç–≤–∞—Ö. –ï—Å–ª–∏ –≤—ã —Ö–æ—Ç–∏—Ç–µ —É–≤–∏–¥–µ—Ç—å —Ç–∏–ø –¥–∞–Ω–Ω—ã—Ö –∑–Ω–∞—á–µ–Ω–∏—è, type () –º–æ–∂–µ—Ç –±—ã—Ç—å –±–æ–ª–µ–µ –ø–æ–¥—Ö–æ–¥—è—â–∏–º. –ù–æ –µ—Å–ª–∏ –≤—ã —Ö–æ—Ç–∏—Ç–µ —É–±–µ–¥–∏—Ç—å—Å—è, —á—Ç–æ –∑–Ω–∞—á–µ–Ω–∏–µ —Ö—Ä–∞–Ω–∏—Ç—Å—è –∫–∞–∫ –æ–ø—Ä–µ–¥–µ–ª–µ–Ω–Ω—ã–π —Ç–∏–ø –¥–∞–Ω–Ω—ã—Ö –∏–ª–∏ —Ç–∏–ø—ã & mdash; –Ω–∞–ø—Ä–∏–º–µ—Ä, —Å—Ç—Ä–æ–∫–∞ –∏–ª–∏ —á–∏—Å–ª–æ —Å –ø–ª–∞–≤–∞—é—â–µ–π –∑–∞–ø—è—Ç–æ–π & mdash;, –≤–∞–º —Å–ª–µ–¥—É–µ—Ç –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å isinstance (). < / p>

–ó–∞–∫–ª—é—á–µ–Ω–∏–µ

–í Python –≤—ã –º–æ–∂–µ—Ç–µ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å —Ñ—É–Ω–∫—Ü–∏—é isinstance (), —á—Ç–æ–±—ã –ø—Ä–æ–≤–µ—Ä–∏—Ç—å, —Å–æ–¥–µ—Ä–∂–∏—Ç –ª–∏ –∑–Ω–∞—á–µ–Ω–∏–µ –æ–ø—Ä–µ–¥–µ–ª–µ–Ω–Ω—ã–π —Ç–∏–ø –¥–∞–Ω–Ω—ã—Ö. –ù–∞–ø—Ä–∏–º–µ—Ä, –µ—Å–ª–∏ –≤—ã —Ö–æ—Ç–∏—Ç–µ —É–±–µ–¥–∏—Ç—å—Å—è, —á—Ç–æ —Å–ø–∏—Å–æ–∫ –∑–Ω–∞—á–µ–Ω–∏–π —Ö—Ä–∞–Ω–∏—Ç—Å—è –∫–∞–∫ —Å–ø–∏—Å–æ–∫, –∏–ª–∏ –µ—Å–ª–∏ —á–∏—Å–ª–æ —Ö—Ä–∞–Ω–∏—Ç—Å—è –∫–∞–∫ —á–∏—Å–ª–æ —Å –ø–ª–∞–≤–∞—é—â–µ–π –∑–∞–ø—è—Ç–æ–π, –≤—ã –º–æ–∂–µ—Ç–µ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å isinstance ().

–í —ç—Ç–æ–º —Ä—É–∫–æ–≤–æ–¥—Å—Ç–≤–µ –ø–æ Python –ø–æ–∫–∞–∑–∞–Ω–æ, –∫–∞–∫ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å isinstance () –¥–ª—è –ø—Ä–æ–≤–µ—Ä–∫–∏ —Ç–æ–≥–æ, —Å–æ–¥–µ—Ä–∂–∏—Ç –ª–∏ –∑–Ω–∞—á–µ–Ω–∏–µ –æ–ø—Ä–µ–¥–µ–ª–µ–Ω–Ω—ã–π —Ç–∏–ø –¥–∞–Ω–Ω—ã—Ö. –¢–µ–ø–µ—Ä—å —É –≤–∞—Å –µ—Å—Ç—å –∏–Ω—Ñ–æ—Ä–º–∞—Ü–∏—è, –Ω–µ–æ–±—Ö–æ–¥–∏–º–∞—è –¥–ª—è –∏—Å–ø–æ–ª—å–∑–æ–≤–∞–Ω–∏—è isinstance () –∫–∞–∫ –º–∞—Å—Ç–µ—Ä–∞ Python.

Shop

Learn programming in R: courses

$

Best Python online courses for 2022

$

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

News


Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method