繁体   English   中英

python中的多行输入

[英]Multiple line input in python

我希望能够添加多个输入,我很确定我需要为此创建一个循环,但不确定如何打印输出的多个副本。

任何帮助,将不胜感激!

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
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:]))

这将提示用户进行新的输入,直到他决定终止程序。

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:]))

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM