Python удалить символ из строки: руководство

–í—ã –º–æ–∂–µ—Ç–µ —É–¥–∞–ª–∏—Ç—å —Å–∏–º–≤–æ–ª –∏–∑ —Å—Ç—Ä–æ–∫–∏ Python —Å –ø–æ–º–æ—â—å—é replace () –∏–ª–∏ translate (). –û–±–∞ —ç—Ç–∏ –º–µ—Ç–æ–¥–∞ –∑–∞–º–µ–Ω—è—é—Ç —Å–∏–º–≤–æ–ª –∏–ª–∏ —Å—Ç—Ä–æ–∫—É –∑–∞–¥–∞–Ω–Ω—ã–º –∑–Ω–∞—á–µ–Ω–∏–µ–º. –ï—Å–ª–∏ —É–∫–∞–∑–∞–Ω–∞ –ø—É—Å—Ç–∞—è —Å—Ç—Ä–æ–∫–∞, –≤—ã–±—Ä–∞–Ω–Ω—ã–π —Å–∏–º–≤–æ–ª –∏–ª–∏ —Å—Ç—Ä–æ–∫–∞ —É–¥–∞–ª—è–µ—Ç—Å—è –∏–∑ —Å—Ç—Ä–æ–∫–∏ –±–µ–∑ –∑–∞–º–µ–Ω—ã.

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

–ù–µ –∏–º–µ–µ—Ç –∑–Ω–∞—á–µ–Ω–∏—è, –∫–∞–∫–æ–π —Å–∏–º–≤–æ–ª –≤—ã —Ö–æ—Ç–∏—Ç–µ —É–¥–∞–ª–∏—Ç—å –∏–∑ —Å—Ç—Ä–æ–∫–∏. Python –ø–æ–º–æ–∂–µ—Ç –≤–∞–º!

–í —ç—Ç–æ–º —Ä—É–∫–æ–≤–æ–¥—Å—Ç–≤–µ –º—ã —Å–æ–±–∏—Ä–∞–µ–º—Å—è –æ–±—Å—É–¥–∏—Ç—å, –∫–∞–∫ —É–¥–∞–ª–∏—Ç—å —Å–∏–º–≤–æ–ª –∏–ª–∏ –Ω–∞–±–æ—Ä —Å–∏–º–≤–æ–ª–æ–≤ –∏–∑ —Å—Ç—Ä–æ–∫–∏. –ü–æ –ø—É—Ç–∏ –º—ã –±—É–¥–µ–º —Å—Å—ã–ª–∞—Ç—å—Å—è –Ω–∞ –Ω–µ—Å–∫–æ–ª—å–∫–æ –ø—Ä–∏–º–µ—Ä–æ–≤.

–ú—ã –æ–±—Å—É–¥–∏–º —Å–ª–µ–¥—É—é—â–∏–µ –ø–æ–¥—Ö–æ–¥—ã:

  • –ò—Å–ø–æ–ª—å–∑–æ–≤–∞–Ω–∏–µ –º–µ—Ç–æ–¥–∞ replace ()
  • –ò—Å–ø–æ–ª—å–∑–æ–≤–∞–Ω–∏–µ –º–µ—Ç–æ–¥ transform ()
  • –£–¥–∞–ª–µ–Ω–∏–µ –ø–æ—Å–ª–µ–¥–Ω–µ–≥–æ —Å–∏–º–≤–æ–ª–∞ —Å –ø–æ–º–æ—â—å—é –∏–Ω–¥–µ–∫—Å–∞—Ü–∏–∏

–î–∞–≤–∞–π—Ç–µ –Ω–∞—á–Ω–µ–º!

–£–¥–∞–ª–∏—Ç—å —Å–∏–º–≤–æ–ª –∏–∑ —Å—Ç—Ä–æ–∫–∏ Python: replace ()

–§—É–Ω–∫—Ü–∏—è string replace () –∑–∞–º–µ–Ω—è–µ—Ç —Å–∏–º–≤–æ–ª –Ω–æ–≤—ã–º —Å–∏–º–≤–æ–ª–æ–º. –≠—Ç—É —Ñ—É–Ω–∫—Ü–∏—é –º–æ–∂–Ω–æ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å –¥–ª—è –∑–∞–º–µ–Ω—ã –ª—é–±–æ–≥–æ —Å–∏–º–≤–æ–ª–∞ –ø—É—Å—Ç–æ–π —Å—Ç—Ä–æ–∫–æ–π.

–ú—ã —Å–æ–∑–¥–∞–µ–º –ø—Ä–æ–≥—Ä–∞–º–º—É, –∫–æ—Ç–æ—Ä–∞—è –ø—Ä–æ—Å–∏—Ç –ø–æ–ª—å–∑–æ–≤–∞—Ç–µ–ª—è –≤—Å—Ç–∞–≤–∏—Ç—å –∏–º—è –ø–æ–ª—å–∑–æ–≤–∞—Ç–µ–ª—è. –í –∏–º–µ–Ω–∏ –ø–æ–ª—å–∑–æ–≤–∞—Ç–µ–ª—è –Ω–µ–ª—å–∑—è –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å –ø–æ–¥—á–µ—Ä–∫–∏–≤–∞–Ω–∏–µ (_). –û—Ç–∫—Ä–æ–π—Ç–µ –Ω–æ–≤—ã–π —Ñ–∞–π–ª Python –∏ –≤—Å—Ç–∞–≤—å—Ç–µ —Å–ª–µ–¥—É—é—â–∏–π –∫–æ–¥:

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

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

–≠—Ç–æ—Ç –∫–æ–¥ –ø—Ä–æ—Å–∏—Ç –ø–æ–ª—å–∑–æ–≤–∞—Ç–µ–ª—è –≤—ã–±–µ—Ä–∏—Ç–µ –∏–º—è –ø–æ–ª—å–∑–æ–≤–∞—Ç–µ–ª—è —Å –ø–æ–º–æ—â—å—é –º–µ—Ç–æ–¥–∞ input () .

–ú–µ—Ç–æ–¥ replace () —É–¥–∞–ª—è–µ—Ç —Å–∏–º–≤–æ–ª –ø–æ–¥—á–µ—Ä–∫–∏–≤–∞–Ω–∏—è –∏–∑ –∏—Å—Ö–æ–¥–Ω–æ–π —Å—Ç—Ä–æ–∫–∏ –∏ –∑–∞–º–µ–Ω—è–µ—Ç –≤—Å–µ —ç–∫–∑–µ–º–ø–ª—è—Ä—ã —ç—Ç–æ–≥–æ —Å–∏–º–≤–æ–ª–∞ –ø—É—Å—Ç–æ–π —Å—Ç—Ä–æ–∫–æ–π. –ó–∞—Ç–µ–º –º—ã –≤—ã–≤–æ–¥–∏–º –∏–º—è –ø–æ–ª—å–∑–æ–≤–∞—Ç–µ–ª—è –±–µ–∑ –ø–æ–¥—á–µ—Ä–∫–∏–≤–∞–Ω–∏—è –Ω–∞ –∫–æ–Ω—Å–æ–ª—å.

–î–∞–≤–∞–π—Ç–µ –∑–∞–ø—É—Å—Ç–∏–º –Ω–∞—à—É –ø—Ä–æ–≥—Ä–∞–º–º—É:

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

–ö–æ–≥–¥–∞ –∏–º—è –ø–æ–ª—å–∑–æ–≤–∞—Ç–µ–ª—è –Ω–µ —Å–æ–¥–µ—Ä–∂–∏—Ç —Å–∏–º–≤–æ–ª–∞ –ø–æ–¥—á–µ—Ä–∫–∏–≤–∞–Ω–∏—è, –Ω–∏—á–µ–≥–æ –Ω–µ –ø—Ä–æ–∏—Å—Ö–æ–¥–∏—Ç.

–£–¥–∞–ª–µ–Ω–∏–µ –Ω–µ—Å–∫–æ–ª—å–∫–∏—Ö —Å–∏–º–≤–æ–ª–æ–≤ —Å –ø–æ–º–æ—â—å—é replace ()

–ß—Ç–æ –ø—Ä–æ–∏–∑–æ–π–¥–µ—Ç, –µ—Å–ª–∏ –≤—ã –∑–∞—Ö–æ—Ç–∏—Ç–µ —É–¥–∞–ª–∏—Ç—å –Ω–µ—Å–∫–æ–ª—å–∫–æ —Å–∏–º–≤–æ–ª–æ–≤ –∏–∑ —Å—Ç—Ä–æ–∫–∏? Python –º–æ–∂–µ—Ç –≤–∞–º –ø–æ–º–æ—á—å. –ú—ã –º–æ–∂–µ–º –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å replace () –≤–Ω—É—Ç—Ä–∏ —Ü–∏–∫–ª–∞ for –¥–ª—è —É–¥–∞–ª–µ–Ω–∏—è –Ω–µ—Å–∫–æ–ª—å–∫–∏—Ö —Å–∏–º–≤–æ–ª–æ–≤ –∏–∑ —Å—Ç—Ä–æ–∫–∏.

–í –Ω–∞—à–µ–º –ø–æ—Å–ª–µ–¥–Ω–µ–º –ù–∞–ø—Ä–∏–º–µ—Ä, –º—ã —É–¥–∞–ª–∏–ª–∏ —Å–∏–º–≤–æ–ª –ø–æ–¥—á–µ—Ä–∫–∏–≤–∞–Ω–∏—è –∏–∑ –∏–º–µ–Ω–∏ –ø–æ–ª—å–∑–æ–≤–∞—Ç–µ–ª—è. –ß—Ç–æ, –µ—Å–ª–∏ –º—ã —Ö–æ—Ç–∏–º —É–¥–∞–ª–∏—Ç—å –≤—Å–µ —Ç–æ—á–∫–∏ (—Ç–æ—á–∫–∏), –ø–æ–¥—á–µ—Ä–∫–∏–≤–∞–Ω–∏—è –∏ –≤–æ—Å–∫–ª–∏—Ü–∞—Ç–µ–ª—å–Ω—ã–µ –∑–Ω–∞–∫–∏ –∏–∑ –Ω–∞—à–µ–π —Å—Ç—Ä–æ–∫–∏? –°–æ–∑–¥–∞–π—Ç–µ –Ω–æ–≤—ã–π —Ñ–∞–π–ª Python –∏ –≤—Å—Ç–∞–≤—å—Ç–µ —ç—Ç–æ—Ç –∫–æ–¥:

–°–Ω–∞—á–∞–ª–∞ –º—ã –ø–æ–ø—Ä–æ—Å–∏–ª–∏ –ø–æ–ª—å–∑–æ–≤–∞—Ç–µ–ª—è –≤—ã–±—Ä–∞—Ç—å –∏–º—è –ø–æ–ª—å–∑–æ–≤–∞—Ç–µ–ª—è. –ó–∞—Ç–µ–º –º—ã –æ–ø—Ä–µ–¥–µ–ª–∏–ª–∏ —Å—Ç—Ä–æ–∫—É, —Å–æ–¥–µ—Ä–∂–∞—â—É—é –≤—Å–µ —Å–∏–º–≤–æ–ª—ã, –∫–æ—Ç–æ—Ä—ã–µ –Ω–µ –¥–æ–ª–∂–Ω—ã –ø–æ—è–≤–ª—è—Ç—å—Å—è –≤ –∏–º–µ–Ω–∏ –ø–æ–ª—å–∑–æ–≤–∞—Ç–µ–ª—è.

–ó–∞—Ç–µ–º –º—ã —Å–æ–∑–¥–∞–ª–∏ —Ü–∏–∫–ª for . –≠—Ç–æ—Ç —Ü–∏–∫–ª for –≤—ã–ø–æ–ª–Ω—è–µ—Ç –∏—Ç–µ—Ä–∞—Ü–∏—é –ø–æ –∫–∞–∂–¥–æ–º—É —Å–∏–º–≤–æ–ª—É –≤ —Å—Ç—Ä–æ–∫–µ " disallowed_characters & rdquo ;. –ù–∞ –∫–∞–∂–¥–æ–π –∏—Ç–µ—Ä–∞—Ü–∏–∏ —Å–∏–º–≤–æ–ª –ø–æ—Å–ª–µ –ø–æ–≤—Ç–æ—Ä–µ–Ω–∏—è —Ü–∏–∫–ª–∞ for –±—É–¥–µ—Ç –∑–∞–º–µ–Ω–µ–Ω–æ –≤ " username " —Å—Ç—Ä–æ–∫–∞ —Å –ø—É—Å—Ç—ã–º —Å–∏–º–≤–æ–ª–æ–º.

–î–∞–≤–∞–π—Ç–µ –∑–∞–ø—É—Å—Ç–∏–º –Ω–∞—à –∫–æ–¥:

–ù–∞—à –∫–æ–¥ –æ—Ç—Ñ–∏–ª—å—Ç—Ä–æ–≤–∞–ª —Ç–æ—á–∫—É –∏ –≤–æ—Å–∫–ª–∏—Ü–∞—Ç–µ–ª—å–Ω—ã–µ –∑–Ω–∞–∫–∏.

–£–¥–∞–ª–∏—Ç—å —Å–∏–º–≤–æ–ª –∏–∑ —Å—Ç—Ä–æ–∫–∏ Python: translate ()

–ú–µ—Ç–æ–¥ Python translate () –∑–∞–º–µ–Ω—è–µ—Ç —Å–∏–º–≤–æ–ª—ã –≤ —Å—Ç—Ä–æ–∫–µ –≤ —Å–æ–æ—Ç–≤–µ—Ç—Å—Ç–≤–∏–∏ —Å —Å–æ–¥–µ—Ä–∂–∏–º—ã–º —Ç–∞–±–ª–∏—Ü—ã —Å–∏–º–≤–æ–ª–æ–≤. –≠—Ç–æ—Ç –º–µ—Ç–æ–¥ –ø—Ä–∏–Ω–∏–º–∞–µ—Ç –æ–¥–∏–Ω –∞—Ä–≥—É–º–µ–Ω—Ç: —Ç–∞–±–ª–∏—Ü—É –ø–µ—Ä–µ–≤–æ–¥–∞ —Å —Å–∏–º–≤–æ–ª–∞–º–∏ –¥–ª—è —Å–æ–ø–æ—Å—Ç–∞–≤–ª–µ–Ω–∏—è.

–ß—Ç–æ–±—ã –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å —ç—Ç–æ—Ç –º–µ—Ç–æ–¥, –Ω–∞–º –Ω—É–∂–Ω–æ —Å–æ–∑–¥–∞—Ç—å —Ç–∞–±–ª–∏—Ü—É –ø–µ—Ä–µ–≤–æ–¥–∞. –í —ç—Ç–æ–π —Ç–∞–±–ª–∏—Ü–µ —É–∫–∞–∑–∞–Ω–æ, –∫–∞–∫–∏–µ —Å–∏–º–≤–æ–ª—ã —Å–ª–µ–¥—É–µ—Ç –∑–∞–º–µ–Ω–∏—Ç—å –≤ —Å—Ç—Ä–æ–∫–µ.

–î–∞–≤–∞–π—Ç–µ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å –º–µ—Ç–æ–¥ translate () –¥–ª—è —É–¥–∞–ª–µ–Ω–∏—è –≤—Å–µ—Ö –ø–æ–¥—á–µ—Ä–∫–∏–≤–∞–Ω–∏–π –∏–∑ –∏–º–µ–Ω–∏ –ø–æ–ª—å–∑–æ–≤–∞—Ç–µ–ª—è:

–≠—Ç–æ—Ç –∫–æ–¥ –∑–∞–º–µ–Ω—è–µ—Ç –≤—Å–µ —ç–∫–∑–µ–º–ø–ª—è—Ä—ã —Ç–µ–≥–∞ " _ " —Å–∏–º–≤–æ–ª —Å–æ –∑–Ω–∞—á–µ–Ω–∏–µ–º None. –ú–µ—Ç–æ–¥ Python ord () –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç –∫–æ–¥ Unicode, —Å–≤—è–∑–∞–Ω–Ω—ã–π —Å " _ " –ø–µ—Ä—Å–æ–Ω–∞–∂. –≠—Ç–æ –∏—Å–ø–æ–ª—å–∑—É–µ—Ç—Å—è –º–µ—Ç–æ–¥–æ–º translate () –¥–ª—è –∏–¥–µ–Ω—Ç–∏—Ñ–∏–∫–∞—Ü–∏–∏ —Å–∏–º–≤–æ–ª–∞, –∫–æ—Ç–æ—Ä—ã–π –º—ã —Ö–æ—Ç–∏–º —É–¥–∞–ª–∏—Ç—å.

–£–¥–∞–ª–µ–Ω–∏–µ –Ω–µ—Å–∫–æ–ª—å–∫–∏—Ö —Å–∏–º–≤–æ–ª–æ–≤ —Å –ø–æ–º–æ—â—å—é translate ()

–í—ã –º–æ–∂–µ—Ç–µ —É–¥–∞–ª–∏—Ç—å –Ω–µ—Å–∫–æ–ª—å–∫–æ —Å–∏–º–≤–æ–ª–æ–≤ –∏–∑ —Å—Ç—Ä–æ–∫–∏ —Å –ø–æ–º–æ—â—å—é translate ().

< p> –ú—ã –º–æ–∂–µ–º —Å–¥–µ–ª–∞—Ç—å —ç—Ç–æ, —Å–æ–∑–¥–∞–≤ –∏—Ç–µ—Ä–∞—Ç–æ—Ä, –∫–æ—Ç–æ—Ä—ã–π –ø–µ—Ä–µ–±–∏—Ä–∞–µ—Ç —Å–ø–∏—Å–æ–∫ —Å–∏–º–≤–æ–ª–æ–≤, –∫–æ—Ç–æ—Ä—ã–µ –º—ã —Ö–æ—Ç–∏–º —É–¥–∞–ª–∏—Ç—å –∏–∑ —Å—Ç—Ä–æ–∫–∏.

–î–∞–≤–∞–π—Ç–µ —É–¥–∞–ª–∏–º –≤—Å–µ –ø–æ–¥—á–µ—Ä–∫–∏–≤–∞–Ω–∏—è, —Ç–æ—á–∫–∏ –∏ –≤–æ—Å–∫–ª–∏—Ü–∞—Ç–µ–ª—å–Ω—ã–µ –∑–Ω–∞–∫–∏ –∏–∑ –∏–º–µ–Ω–∏ –ø–æ–ª—å–∑–æ–≤–∞—Ç–µ–ª—è: < / p>

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

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

< p> –ú–µ—Ç–æ–¥ translate () –ø—Ä–æ–≤–µ—Ä—è–µ—Ç, —Å–æ–æ—Ç–≤–µ—Ç—Å—Ç–≤—É–µ—Ç –ª–∏ –∫–∞–∂–¥—ã–π —Å–∏–º–≤–æ–ª –≤ —Å—Ç—Ä–æ–∫–µ " username " —Ç–æ—á–∫–µ –ø–æ–ª–Ω–æ–π –æ—Å—Ç–∞–Ω–æ–≤–∫–µ, –≤–æ—Å–∫–ª–∏—Ü–∞—Ç–µ–ª—å–Ω–æ–º—É –∑–Ω–∞–∫—É –∏–ª–∏ –ø–æ–¥—á–µ—Ä–∫–∏–≤–∞–Ω–∏—é. –ï—Å–ª–∏ –æ–¥–∏–Ω –∏–∑ —ç—Ç–∏—Ö —Å–∏–º–≤–æ–ª–æ–≤ –Ω–∞–π–¥–µ–Ω, –æ–Ω –∑–∞–º–µ–Ω—è–µ—Ç—Å—è –Ω–∞ None. –≠—Ç–æ —É–¥–∞–ª—è–µ—Ç —Å–∏–º–≤–æ–ª –∏–∑ —Å—Ç—Ä–æ–∫–∏.

–ú—ã –∏—Å–ø–æ–ª—å–∑—É–µ–º –ø–æ–Ω–∏–º–∞–Ω–∏–µ —Å–ø–∏—Å–∫–∞ Python –¥–ª—è –ø–µ—Ä–µ–±–æ—Ä–∞ –∫–∞–∂–¥–æ–≥–æ —Å–∏–º–≤–æ–ª–∞ –≤ –Ω–∞—à–µ–º —Å–ø–∏—Å–∫–µ –∏—Å–∫–ª—é—á–µ–Ω–Ω—ã—Ö —Å–∏–º–≤–æ–ª–æ–≤.

–î–∞–≤–∞–π—Ç–µ –ø—Ä–æ—Ç–µ—Å—Ç–∏—Ä—É–µ–º –Ω–∞—à—É –ø—Ä–æ–≥—Ä–∞–º–º—É:

–ù–∞—à –∫–æ–¥ —É—Å–ø–µ—à–Ω–æ —É–¥–∞–ª–∏–ª –≤—Å–µ —É–∫–∞–∑–∞–Ω–Ω—ã–µ –Ω–∞–º–∏ —Å–ø–µ—Ü–∏–∞–ª—å–Ω—ã–µ —Å–∏–º–≤–æ–ª—ã –∏–∑ –Ω–∞—à–µ–π —Å—Ç—Ä–æ–∫–∏.

Python: —É–¥–∞–ª–∏—Ç—å –ø–æ—Å–ª–µ–¥–Ω–∏–π —Å–∏–º–≤–æ–ª –∏–∑ —Å—Ç—Ä–æ–∫–∏ < / h2>

–ß—Ç–æ–±—ã —É–¥–∞–ª–∏—Ç—å –ø–æ—Å–ª–µ–¥–Ω–∏–π —Å–∏–º–≤–æ–ª –∏–∑ —Å—Ç—Ä–æ–∫–∏ g –∏—Å–ø–æ–ª—å–∑—É–π—Ç–µ –æ–±–æ–∑–Ω–∞—á–µ–Ω–∏–µ —Å—Ä–µ–∑–∞ [: -1]. –≠—Ç–æ –æ–±–æ–∑–Ω–∞—á–µ–Ω–∏–µ –≤—ã–±–∏—Ä–∞–µ—Ç —Å–∏–º–≤–æ–ª –≤ –ø–æ–∑–∏—Ü–∏–∏ –∏–Ω–¥–µ–∫—Å–∞ -1 (–ø–æ—Å–ª–µ–¥–Ω–∏–π —Å–∏–º–≤–æ–ª –≤ —Å–ø–∏—Å–∫–µ). –ó–∞—Ç–µ–º —Å–∏–Ω—Ç–∞–∫—Å–∏—Å –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç –∫–∞–∂–¥—ã–π —Å–∏–º–≤–æ–ª, –∫—Ä–æ–º–µ —ç—Ç–æ–≥–æ.

–°–∏–Ω—Ç–∞–∫—Å–∏—Å –¥–ª—è —É–¥–∞–ª–µ–Ω–∏—è –ø–æ—Å–ª–µ–¥–Ω–µ–≥–æ —Å–∏–º–≤–æ–ª–∞ –∏–∑ —Å—Ç—Ä–æ–∫–∏:

–ü—Ä–∏–º–µ—Ä —É–¥–∞–ª–µ–Ω–∏—è –ø–æ—Å–ª–µ–¥–Ω–µ–≥–æ —Å–∏–º–≤–æ–ª–∞

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

–ù–∞–ø—Ä–∏–º–µ—Ä, –∑–Ω–∞—á–µ–Ω–∏–µ " M " —Å–æ–æ–±—â–∞–µ—Ç –Ω–∞–º, —á—Ç–æ —Å–æ—Ç—Ä—É–¥–Ω–∏–∫ —Ä–∞–±–æ—Ç–∞–µ—Ç –≤ –æ—Ç–¥–µ–ª–µ –º–∞—Ä–∫–µ—Ç–∏–Ω–≥–∞. –ú—ã —Å–æ–±–∏—Ä–∞–µ–º—Å—è —É–¥–∞–ª–∏—Ç—å —ç—Ç–æ–≥–æ –ø–µ—Ä—Å–æ–Ω–∞–∂–∞. –≠—Ç–∞ —Å–∏—Å—Ç–µ–º–∞ –æ—Ç—Å–ª–µ–∂–∏–≤–∞–Ω–∏—è —Å–æ—Ç—Ä—É–¥–Ω–∏–∫–æ–≤ –∑–∞–º–µ–Ω—è–µ—Ç—Å—è –Ω–æ–≤–æ–π —Å–∏—Å—Ç–µ–º–æ–π. –ù–æ–≤–∞—è —Å–∏—Å—Ç–µ–º–∞ –æ—Ç—Å–ª–µ–∂–∏–≤–∞–µ—Ç –æ—Ç–¥–µ–ª, –≤ –∫–æ—Ç–æ—Ä–æ–º —Ä–∞–±–æ—Ç–∞–µ—Ç —Å–æ—Ç—Ä—É–¥–Ω–∏–∫.

–ù–∞—á–Ω–µ–º —Å —Ç–æ–≥–æ, —á—Ç–æ –ø–æ–ø—Ä–æ—Å–∏–º –ø–æ–ª—å–∑–æ–≤–∞—Ç–µ–ª—è –≤—Å—Ç–∞–≤–∏—Ç—å –∏–¥–µ–Ω—Ç–∏—Ñ–∏–∫–∞—Ç–æ—Ä —Å–æ—Ç—Ä—É–¥–Ω–∏–∫–∞ —Å –ø–æ–º–æ—â—å—é –º–µ—Ç–æ–¥–∞ input () :

–î–∞–ª–µ–µ , –º—ã —É–¥–∞–ª—è–µ–º –ø–æ—Å–ª–µ–¥–Ω–∏–π —Å–∏–º–≤–æ–ª –∏–∑ –∏–¥–µ–Ω—Ç–∏—Ñ–∏–∫–∞—Ç–æ—Ä–∞:

[: -1] - —ç—Ç–æ –æ–ø–µ—Ä–∞—Ü–∏—è —Å—Ä–µ–∑–∞ —Å—Ç—Ä–æ–∫–∏ , –∫–æ—Ç–æ—Ä–∞—è —É–¥–∞–ª—è–µ—Ç –ø–æ—Å–ª–µ–¥–Ω–∏–π —Å–∏–º–≤–æ–ª –∏–∑ —Å–ø–∏—Å–∫–∞. –ú—ã –∏—Å–ø–æ–ª—å–∑—É–µ–º –æ—Ç—Ä–∏—Ü–∞—Ç–µ–ª—å–Ω—É—é –∏–Ω–¥–µ–∫—Å–∞—Ü–∏—é –¥–ª—è –∏–∑–≤–ª–µ—á–µ–Ω–∏—è —ç–ª–µ–º–µ–Ω—Ç–æ–≤. —Å –∫–æ–Ω—Ü–∞ —Å—Ç—Ä–æ–∫–∏. –¢–µ–ø–µ—Ä—å –≤—ã–≤–µ–¥–∏—Ç–µ –Ω–∞ –∫–æ–Ω—Å–æ–ª—å –Ω–æ–≤—ã–π –∏–¥–µ–Ω—Ç–∏—Ñ–∏–∫–∞—Ç–æ—Ä —Å–æ—Ç—Ä—É–¥–Ω–∏–∫–∞:

–ù–∞—à–∞ –ø—Ä–æ–≥—Ä–∞–º–º–∞ —É–¥–∞–ª—è–µ—Ç –ø–æ—Å–ª–µ–¥–Ω–µ–µ –∑–Ω–∞—á–µ–Ω–∏–µ –≤ –∏–¥–µ–Ω—Ç–∏—Ñ–∏–∫–∞—Ç–æ—Ä–µ —Å–æ—Ç—Ä—É–¥–Ω–∏–∫–∞.

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

–í—ã –º–æ–∂–µ—Ç —É–¥–∞–ª–∏—Ç—å —Å–∏–º–≤–æ–ª –∏–ª–∏ –Ω–µ—Å–∫–æ–ª—å–∫–æ —Å–∏–º–≤–æ–ª–æ–≤ –∏–∑ —Å—Ç—Ä–æ–∫–∏ —Å –ø–æ–º–æ—â—å—é replace () –∏–ª–∏ translate (). –û–±–∞ –º–µ—Ç–æ–¥–∞ replace () –∏ translate () –≤–æ–∑–≤—Ä–∞—â–∞—é—Ç –æ–¥–∏–Ω –∏ —Ç–æ—Ç –∂–µ —Ä–µ–∑—É–ª—å—Ç–∞—Ç: —Å—Ç—Ä–æ–∫—É –±–µ–∑ —É–∫–∞–∑–∞–Ω–Ω—ã—Ö –≤–∞–º–∏ —Å–∏–º–≤–æ–ª–æ–≤.

–î–ª—è –Ω–æ–≤–∏—á–∫–æ–≤ –º–µ—Ç–æ–¥ replace () –ø—Ä–æ—â–µ –≤ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞–Ω–∏–∏. –≠—Ç–æ –ø–æ—Ç–æ–º—É, —á—Ç–æ –æ–Ω –ø—Ä–∏–Ω–∏–º–∞–µ—Ç —Ç–æ–ª—å–∫–æ –¥–≤–∞ –ø–∞—Ä–∞–º–µ—Ç—Ä–∞.

–ü–µ—Ä–≤—ã–π –ø–∞—Ä–∞–º–µ—Ç—Ä - —ç—Ç–æ —Å–∏–º–≤–æ–ª, –∫–æ—Ç–æ—Ä—ã–π –≤—ã —Ö–æ—Ç–∏—Ç–µ –∑–∞–º–µ–Ω–∏—Ç—å. –ù–∞—à –≤—Ç–æ—Ä–æ–π –ø–∞—Ä–∞–º–µ—Ç—Ä - —ç—Ç–æ –∑–Ω–∞—á–µ–Ω–∏–µ, –∫–æ—Ç–æ—Ä—ã–º –≤—ã —Ö–æ—Ç–∏—Ç–µ –∑–∞–º–µ–Ω–∏—Ç—å —Å–∏–º–≤–æ–ª. –ï—Å–ª–∏ –≤—ã —Ö–æ—Ç–∏—Ç–µ –∑–∞–º–µ–Ω–∏—Ç—å –Ω–µ—Å–∫–æ–ª—å–∫–æ —Å–∏–º–≤–æ–ª–æ–≤, –≤—ã –º–æ–∂–µ—Ç–µ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å —Ü–∏–∫–ª for.

–•–æ—Ç–∏—Ç–µ —É–∑–Ω–∞—Ç—å –±–æ–ª—å—à–µ –æ Python? –û–∑–Ω–∞–∫–æ–º—å—Ç–µ—Å—å —Å –Ω–∞—à–∏–º –ø–æ–ª–Ω—ã–º —Ä—É–∫–æ–≤–æ–¥—Å—Ç–≤–æ–º –ø–æ –∏–∑—É—á–µ–Ω–∏—é 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