Python 2.7 如果===语句,如何跳过python上的一行?

Python 2.7 如果===语句,如何跳过python上的一行?,python-2.7,Python 2.7,如果我选择2并转到Coin进行买卖,我如何跳过比特币进行消费 #Bittrex Buy and Sell choice=float(raw_input("Enter 1 Buy, 2 Sell : ")) if (choice!=1): if (choice!=2): sys.exit('Choice number {0} not valid. Please enter 1 to Buy or 2 to Sell'.format(choice)) #Bit

如果我选择2并转到Coin进行买卖,我如何跳过比特币进行消费

#Bittrex Buy and Sell
choice=float(raw_input("Enter 1 Buy, 2 Sell :       "))
if (choice!=1):
    if (choice!=2): 
        sys.exit('Choice number {0} not valid. Please enter 1 to Buy or 2 to Sell'.format(choice))

#Bitcoin to spend
bitcoin=float(raw_input("Bitcoin to Spend: "))

#Market to trade at
trade = 'BTC'

#Coint to Buy
currency = raw_input("Coin: ")

虽然我不会这样做,但这是一种更干净的方式来处理您所追求的方法

#Bittrex Buy and Sell
choice=float(raw_input("Enter 1 Buy, 2 Sell :       "))
if choice not in [1,2]:
    sys.exit('Choice number {0} not valid. Please enter 1 to Buy or 2 to Sell'.format(choice))

if choice == 1:
    #Bitcoin to spend
    bitcoin=float(raw_input("Bitcoin to Spend: "))

if choice == 2:
    #Coint to Buy
    currency = raw_input("Coin: ")

#Market to trade at
trade = 'BTC'

如果需要,可以修复缩进或再添加一个缩进