我希望能够添加多个输入,并且我非常确定需要为此创建一个循环,但不确定如何打印输出的多个副本。
任何帮助都将不胜感激!
mac_hex = input("Enter AP Ethernet Mac Address:")
mac_dec = int(mac_hex, 16)
print (" ")
print ("The Ethernet MAC address is " + (mac_hex))
print (" ")
print ("2.4 Ghz Radio MAC Addresses are as follows")
print ("Radio #1 = " + (hex(mac_dec+35)[2:]))
print ("Radio #2 = " + (hex(mac_dec+45)[2:]))
enter code here
发布于 2018-07-04 02:31:59
while True:
mac_hex = input("Enter AP Ethernet Mac Address, leave empty to exit:")
if not mac_hex.strip():
break
mac_dec = int(mac_hex, 16)
print (" ")
print ("The Ethernet MAC address is " + (mac_hex))
print (" ")
print ("2.4 Ghz Radio MAC Addresses are as follows")
print ("Radio #1 = " + (hex(mac_dec+35)[2:]))
print ("Radio #2 = " + (hex(mac_dec+45)[2:]))
发布于 2018-07-04 02:57:11
这将提示用户输入新的内容,直到他决定终止程序为止。
mac_hex = ''
while mac_hex != 'quit':
mac_hex = input("Enter AP Ethernet Mac Address:")
if mac_hex != 'quit':
mac_dec = int(mac_hex, 16)
print (" ")
print ("The Ethernet MAC address is " + (mac_hex))
print (" ")
print ("2.4 Ghz Radio MAC Addresses are as follows")
print ("Radio #1 = " + (hex(mac_dec+35)[2:]))
print ("Radio #2 = " + (hex(mac_dec+45)[2:]))
https://stackoverflow.com/questions/51160839
复制相似问题