[英]function set value for another function
How can I make the functions 我该如何做功能
def InputName():
Name = input("Name: ")
def InputCourseName():
CourseName = input("Course: ")
set the Name and CourseName for me to use in: 设置我要使用的名称和课程名称:
def Criacao(Name, CourseName):
global Fonte, Output, CorTexto, Raw
base = Image.open(Raw)
draw = ImageDraw.Draw(base)
draw.text((5,5), Name.upper(), font=Fonte, fill=CorTexto)
draw.text((6,5), CourseName.upper(), font=Fonte, fill=CorTexto)
Would it work if I ran: Criacao(InputName(), InputCourseName())
? 如果我运行了,它将起作用:
Criacao(InputName(), InputCourseName())
吗?
You should start using return
您应该开始使用
return
def InputName():
name = input("Name: ")
return name
def InputCourseName():
courseName = input("Course: ")
return courseName
Then you can use the returned values to assign to local variables 然后,您可以使用返回的值分配给局部变量
def Criacao():
name = InputName() # We are using the returned values here
courseName = InputCourseName()
global Fonte, Output, CorTexto, Raw
base = Image.open(Raw)
draw = ImageDraw.Draw(base)
draw.text((5,5), name.upper(), font=Fonte, fill=CorTexto)
draw.text((6,5), courseName.upper(), font=Fonte, fill=CorTexto)
是的, 如果您从InputName()
函数返回Name
并从InputCourseName()
函数返回CourseName
, InputCourseName()
起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.