當前位置:首頁 » 編程語言 » python菜單

python菜單

發布時間: 2022-08-15 20:22:17

python要編寫一個完整的程序,需要創建新的文件。應該選擇什麼菜單創建

從用戶獲取文件名並創建同名文件的函數。然後,函數應該使用while循環來處理文件,並允許用戶輸入要寫入文件的多個整數。
使用for循環讀取文件內容並將其輸出到屏幕的函數。
向文件中追加若干整數的函數。
計算文件中包含的數字總數並列印

⑵ 為什麼python窗體里菜單與簡單計算器兩者顯示不出來

檢查mac菜單欄和代碼。
python窗體里菜單代碼運行良好缺不顯示的話,可以檢查mac菜單欄,需要單擊窗體,會顯示一個下拉菜單欄,這樣菜單就會顯示了,簡單計算器顯示不出來可能是代碼出現錯誤,例如重復運算符金額小數點出現錯誤,建議檢查代碼有沒有出錯。

⑶ python tkinter 做一個菜單

你這不是菜單,你這是下拉列表框,combobox控制項。tkinter默認是不帶的。

但是TKINTER有一個「隱藏功能」,導入ttk主題庫後,你就可以用ComboBox等高級控制項了。

給你個例子,你就知道怎麼寫了。

# -*- coding: UTF-8 -*-
# 獲取ODBC數據源列表
from tkinter import *
from tkinter import ttk
import win32api,win32con


def GetODBCdsn():
key = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER,
'SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources',0, win32con.KEY_ALL_ACCESS)
#print(key)
#print(win32api.RegQueryValue(key,''))
#print('返回項的子項數目、項值數目,以及最後一次修改時間',win32api.RegQueryInfoKey(key))
subitem, item, opdate =win32api.RegQueryInfoKey(key)
dsnlist=[]
for i in range(item):
print('---',win32api.RegEnumValue(key, i))
dsnName,dsnObject,dsnType = win32api.RegEnumValue(key, i)
dsnlist.append(dsnName)
#print(dir(win32api))
win32api.RegCloseKey(key)
return dsnlist


class MFrame(Frame):
def __init__(self, master=None, cnf={}, **kw):
self.master = master
self.master.title('獲取用戶定義的數據源')
self.combo = ttk.Combobox(self.master)
self.combo.config(state="readonly")
self.combo.pack(side=TOP, fill = 'x', expand = False)
self.combo.update_idletasks()
comlist=GetODBCdsn()
self.combo['values'] = comlist


def test():
GetODBCdsn()
def main():
root = Tk()
mf=MFrame(root)
root.mainloop()
if __name__=="__main__":
#test()
main()

⑷ python怎麼使用

Python是一種計算機程序設計語言,也是人工智慧時代的語言,初的時候是被設計用於編寫自動化腳本,但是現在隨著版本的不斷更新以及其他功能的添加,現在 Python已經被廣泛的應用於ー些大型開發上面。在少兒編程領域,Python也逐漸成為孩子們深入系統學習編程的基礎語言。

⑸ python菜單程序

你不是用qt開發界面的也不是用tkinter開發

只是原始的代碼的話
最簡單的方法是用
if
else if
else if
else
這樣的,在python裡面貌似沒有類似C語言的swtich
所以還是用最基本的方法吧

這個對於有一點的編程基礎的同學來的話是相當簡單的
python以她代碼精簡精悍聞名,所以越到後面你會體會到的
當然還有其他方法實現你說的,對於初學者的你我建議你還是把if學好,基本的判斷在任何語言中都是基礎的
/************************電泡泡**************************/
ps:有疑問請直接hi我,或者email [email protected],對了我可以推薦一些python的教材和視頻給你

望採納..

⑹ 下載Python後右鍵菜單變長

這並不會影響你的操作,如果你是強迫證的話還是需要改的,
解決方法是:在安裝的時候不要選擇Add lauchers dir to the PATH 就行了
另外安裝PYCharm後右鍵打開桌面項目導致菜單欄變寬解決方法是運行regedit注冊表; 按以下路徑,HKEY_CLASSES_ Community Edition ,找到PyCharm Community Edition文件夾,刪除.即可

⑺ python游戲菜單問題,本人python小白,求大佬解決幫一下

while True:
num = ('1','2','3','4','0')
menu = ('游戲設置','選擇游戲級別','我的裝備','我的積分','退出')
mapping = dict(zip(num, menu))
print(' '.join(['.'.join(x) for x in mapping.items()]))
choice = input('請輸入菜單項對應的數字:')
print(mapping.get(choice, '選項不存在') if choice!='0' else '謝謝使用', end=' ')
if choice == '0':
break

⑻ python文本菜單的程序

#!/usr/bin/envpython3#py3.6+
"""
#要求做一個系統菜單,輸入數字進入對應菜單,包含以下內容,正常操作不能報錯:
#菜單1:列印所有產品價格和庫存
#菜單2:修改產品價格
#菜單3:增加庫存
#菜單4:購買指定數量產品
#菜單5:增加新產品作為思考題
#菜單0:退出當前系統
"""

price={'vegetables':'3','eggs':'4','rice':'2'}#價格dict
stock={'vegetables':'0','eggs':'0','rice':'0'}#庫存dict

tip='''
1:列印所有產品價格和庫存
2:修改產品價格
3:增加庫存
4:購買指定數量產品
5:增加新產品作為思考題
0:退出當前系統
'''

defmain():
whileTrue:
globalprice,stock
a=input(f'Pleaseenteranumber:{tip} ').strip()
ifa=='0':
print('Exit!')
break
elifa=='1':
style='{:15}{:6}{:5}'
print(style.format('Name','price','stock'))
for(n,p),(_,s)inzip(price.items(),stock.items()):
print(style.format(n,p,s))
print()
elifa=='2':
whileTrue:
n=input(':')
ifninprice:
break
print('invalidinput!Shouldbe"{}".'.format(
'"or"'.join(price)))
p=input('enteranewpriceofthisproct:')
price[n]=p
elifa=='3':
whileTrue:
n=input(':')
ifninstock:
break
print('Invalidinput!Shouldbe"{}".'.format(
'"or"'.join(stock)))
whileTrue:
s=input(':')
try:
s=int(s)
break
except:
print('Invalidinput,mustbeainteger!')
stock[n]=str(int(stock[n])+s)
elifa=='4':
whileTrue:
n=input('enteraproctnametobuyit:')
ifninstock:
break
print('Invalidinput!Shouldbe"{}".'.format(
'"or"'.join(stock)))
whileTrue:
s=input('enteraintegerforhowmanytobuy:')
try:
s=int(s)
ifs<=0ors>int(stock[n]):
raise
break
except:
print('Invalidinput,mustbeapositiveintegerand'
'lessthan{}!'.format(stock[n]))
y=input('Youwanttobuy{}X{},whichcost{}?(y)/n'.format(
n,s,int(price[n])*s))
ify.strip().lower()in('y',''):
stock[n]=str(int(stock[n])-s)
print('Youpay{}andget{}{}'.format(int(price[n]*s),s,n))
elifa=='5':
print('Uncomplete... ')

if__name__=='__main__':
main()

熱點內容
n皇後問題演算法 發布:2024-04-16 17:42:47 瀏覽:235
資料庫相關論文 發布:2024-04-16 17:20:31 瀏覽:16
中山php培訓 發布:2024-04-16 16:57:29 瀏覽:951
java類實例 發布:2024-04-16 16:26:59 瀏覽:706
ipa編譯和反編譯 發布:2024-04-16 16:03:46 瀏覽:634
驗證身份證的密碼是什麼密碼 發布:2024-04-16 16:03:34 瀏覽:948
每個函數都能獨立的編譯 發布:2024-04-16 15:54:39 瀏覽:749
javacdll 發布:2024-04-16 15:24:55 瀏覽:608
編譯js代碼 發布:2024-04-16 15:16:20 瀏覽:32
gcc編譯教程 發布:2024-04-16 15:16:13 瀏覽:703