日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

python中主函数循环,带有菜单函数的Python主函数循环不起作用?

發(fā)布時間:2023/12/10 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python中主函数循环,带有菜单函数的Python主函数循环不起作用? 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

我現(xiàn)在是一名大學(xué)生,正在上python課程。我們的任務(wù)是用函數(shù)創(chuàng)建這個程序。main函數(shù)調(diào)用菜單,然后在main函數(shù)中編寫一個循環(huán),根據(jù)菜單函數(shù)中的用戶響應(yīng)訪問其他函數(shù)。在

我好像不能讓我的循環(huán)工作。當(dāng)我選擇一個菜單選項(xiàng)時,什么都不會發(fā)生。現(xiàn)在,我只有print語句來測試函數(shù)的調(diào)用。在我編寫函數(shù)之前,我要確保它能正常工作。在

如果有人有一個循環(huán)調(diào)用函數(shù)應(yīng)該是什么樣的示例,這將對我有很大幫助。在def GetChoice():

#Function to present the user menu and get their choice

#local variables

UserChoice = str()

#Display menu and get choice

print()

print("Select one of the options listed below: ")

print("\tP\t==\tPrint Data")

print("\tA\t==\tGet Averages")

print("\tAZ\t==\tAverage Per Zone")

print("\tAL\t==\tAbove Levels by Zone")

print("\tBL\t==\tBelow Levels")

print("\tQ\t==\tQuit")

print()

UserChoice = input("Enter choice: ")

print()

UserChoice = UserChoice.upper()

return UserChoice

def PrintData():

print("test, test, test")

def AverageLevels():

print("test, test, test")

def AveragePerZone():

print("test, test, test")

def AboveLevels():

print("test, test, test")

def BelowLevels():

print("test, test, test")

def main():

Choice = str()

#call GetChoice function

GetChoice()

#Loop until user quits

if Choice == 'P':

PrintData()

elif Choice == 'A':

AverageLevels()

elif Choice == 'AZ':

AveragePerZone()

elif Choice == 'AL':

AboveLevels()

elif Choice == 'BL':

BelowLevels()

main()

總結(jié)

以上是生活随笔為你收集整理的python中主函数循环,带有菜单函数的Python主函数循环不起作用?的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。