国产成人AV一区二区三区在线_国产成人精品无码免费看_国产成人无码无卡在线观看_国产精品成人A区在线观看_国产日韩精品欧美一区_国产亚洲精品自在久久蜜TV_久草热久草热线频97精品_久久久噜噜噜久久中文福利_久久婷婷五月综合色国产免费观看_日日狠狠久久偷偷色综合0,九一桃色在线观看,久久97精品久久久久久久不卡,国产成人精品亚洲精品

pythontkinter如何判斷Entry文本框中是否有小數(shù)點,?

訪客2025-02-10 09:27:331

代碼如下:from tkinter import *def main():root = Tk()root.title('calculator')a = Variable()e1 = Entry(root,width=28,bd=0,textvariable=a)e1.place(x=0,y=0)def b(): c = e1.get()+str(1) a.set(c)def b1(): c = e1.get()+str(2) a.set(c)def b2(): c = e1.get()+str(3) a.set(c)def b3(): c = e1.get() + str(4) a.set(c)def b4(): c = e1.get() + str(5) a.set(c)def b5(): c = e1.get() + str(6) a.set(c)def b6(): c = e1.get() + str(7) a.set(c)def b7(): c = e1.get() + str(8) a.set(c)def b8(): c = e1.get() + str(9) a.set(c)def b9(): c = e1.get()+str(0) a.set(c) def bd(): c = e1.get() if c=='': c1 = c+str('0.') a.set(c1) else: pass Button(root,text='1',width=3,height=1,bd=1,command=b).place(x=0,y=80) Button(root,text='2',width=3,height=1,bd=1,command=b1).place(x=30,y=80) Button(root,text='3',width=3,height=1,bd=1,command=b2).place(x=60,y=80) Button(root,text='4',width=3,height=1,bd=1,command=b3).place(x=0,y=110) Button(root,text='5',width=3,height=1,bd=1,command=b4).place(x=30,y=110) Button(root,text='6',width=3,height=1,bd=1,command=b5).place(x=60,y=110) Button(root,text='7',width=3,height=1,bd=1,command=b6).place(x=0,y=140) Button(root,text='8',width=3,height=1,bd=1,command=b7).place(x=30,y=140) Button(root,text='9',width=3,height=1,bd=1,command=b8).place(x=60,y=140) Button(root,text='0',width=6,height=1,bd=1,command=b9).place(x=0,y=170) Button(root,text='.',width=3,height=1,bd=1,command=bd).place(x=60,y=170) mainloop()if __name__ == '__main__': main()可見我這是在編譯該計算器,,但是我在弄小數(shù)點的按鈕的時候遇到了困難,就是我無法判斷在按下'.'按鈕前Entry文本框中是否有其他小數(shù)點,怎么辦呢,?

在你的bd()中增加以下代碼:

pythontkinter如何判斷Entry文本框中是否有小數(shù)點,?

(str函數(shù)可以去掉,,因為你本身加的就是字串)

文章評論