PyThon3函数的使用

Posted Jumpkin1122

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PyThon3函数的使用相关的知识,希望对你有一定的参考价值。

代码:

def fun1():
    print("hello")
    
def fun2(str):
    str += "!"
    return str
 
def fun3(str="hello!"):
    print(str)
 
def fun4(str1, str2=":", *args):
    print(str1+str2, args)
 
 
if __name__ == __main__:
    fun1()
    str = fun2("hello")
    print(str)
    fun3("hi!")
    fun3()
    fun4("num",":", 1,2,3,4,5
 

运行结果:

hello
hello!
hi!
hello!
num: (1, 2, 3, 4, 5)

 

以上是关于PyThon3函数的使用的主要内容,如果未能解决你的问题,请参考以下文章