1 2 3 4 5 6 7 8 9 10 11 12 13 | # # µû¶óÇÏ¸ç ¹è¿ì´Â ÆÄÀ̽ã°ú µ¥ÀÌÅÍ°úÇÐ(»ý´ÉÃâÆÇ»ç 2020) # 9.11 Á¤±Ô½Ä¿¡¼ ƯÁ¤ ¹®ÀÚ¸¦ ´ëüÇÏ´Â ÇÔ¼ö : sub(), 242ÂÊ # import re s = 'My lucky number 2 7 99' def hash_by_mult_and_modulo(m): n = int(m.group()) # ¸ÅĪµÈ ¹®ÀÚ¿À» °¡Á®¿Í¼ Á¤¼ö·Î º¯È¯ return str(n * 23435 % 973) # ¼ýÀÚ¿¡ ÇؽÃÇÔ¼ö¸¦ Àû¿ëÇÏ°í ¹®ÀÚ¿·Î ¸¸µé¾î ¹Ýȯ print(re.sub('[0-9]+', hash_by_mult_and_modulo, s)) | cs |