Created
May 4, 2020 11:48
-
-
Save emilgaripov/964f4349f634a7f47e835928e01e36b6 to your computer and use it in GitHub Desktop.
Final mac address
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Задание 4.7 | |
Преобразовать MAC-адрес mac в двоичную строку такого вида: | |
'101010101010101010111011101110111100110011001100' | |
Ограничение: Все задания надо выполнять используя только пройденные темы. | |
''' | |
mac = 'AAAA:BBBB:CCCC' | |
mac_div_str = mac.strip().split(':') # разделяем строку по символу ":" | |
mac_join_str = ''.join(mac_div_str) # объединяем строку | |
#mac_ = bin(mac_) # преобразуем сначала в двоичное число | |
#print(mac_, type(mac_)) # выводим на экран значение и тип переменной | |
mac_hex = int(mac_join_str, 16) # преобразуем в шестнадцатеричное значение | |
mac_bin = bin(mac_hex) # преобразуем в двоичное значение | |
mac_final = mac_bin.lstrip('0b') # вырезаем 0b из строки | |
print(mac_final) # выводим на экран |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment