def preme(a):
print "function in function ?"
def prit(a):
a+=1
return a
a =1
while a ==1:
preme(a)
Làm sao để gọi 1 hàm bên trong 1 hàm trong Python?
Code của bạn
def preme(a):
print "function in function ?"
def prit(a):
a+=1
return a
a =1
while a ==1:
preme(a)
tóm lại là bạn muốn làm gì?
2 Likes
Mình gọi được cái hàm preme, nhưng không biết làm sao để gọi cái hàm bên trong nó ra ngoài đó bạn
Bạn đưa prit() ra ngoài preme() thôi nhé.
2 Likes
Mình đang muốn kéo cái hàm con ra để kết thúc vòng lập
Vậy thì bạn lựa chọn cách code khác để rõ ràng hơn nhé.
2 Likes
from Tkinter import *
from tkFont import Font
import Tkinter
import tkMessageBox
import time
import random
tex=[
"If you don't try \n You'll never Know! ",
"SHARK have no \n Swim Bladder!",
"Do you want to REGRET\nOr SUCCESS\n?",
"I don't believe in the GENIUS\nI believe in the so F*CKING HARD PAIN\n!"
]
secure_random = random.SystemRandom()
color = ['red','green', 'white', 'pink','skyblue']
#Options button
def menu_class(a,b):
def stopa(a,b):
a = a*b
return a
print "-----------b", b
mb = Menubutton(top, text="Option"
,bg="black"
,fg="white"
,font="Tohoma 10 bold"
,highlightbackground="black"
,borderwidth=0)
#,anchor="w"
mb.menu = Menu(mb, tearoff=0)
mb["menu"] = mb.menu
add_more_tex = IntVar()
mb.menu.add_checkbutton( label="Add more text"
,font="Tohoma 10 bold",variable=add_more_tex)
mb.menu.add_command (label="Stop",font="Tohoma 10 bold",command= stopa(a,b)
,foreground="white",background="black")
mb.pack(fill="both",side=Tkinter.TOP)
# show tex and kill
def loop_for_tk():
show_power = Tkinter.Button(top, text=secure_random.choice(tex)
,highlightbackground="black"
,font="Verdana 38 bold"
,fg= secure_random.choice(color)
,bg = "black"
,borderwidth=-5
,height=5
,command= top.destroy)
show_power.pack(fill="both",side=Tkinter.TOP)
#top.mainloop()
a=1
b = 123
while a==1:
top = Tkinter.Tk()
top.title("Your Goal")
loop_for_tk()
menu_class(a,b)
top.mainloop()
# minh can dua cai ham con vao day de ket thuc vong lap
time.sleep(1)
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?