簡體   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