不同于其他语言,python支持函数返回多个值
为函数提供说明文档:help(函数名)或者函数名.__doc__
def str_max(str1, str2):
'''
比较两个字符串的大小
'''
str = str1 if str1 > str2 else str2
return str
help(str_max)
print(str_max.__doc__)
Help on built-in function len in module builtins:
len(obj, /)
Return the number of items in a container.
out[2]:'Return the number of items in a container.'
def demo(obj)
obj += obj
print("形参值为:",obj)
print("---值传递---")
a = "孙悟空"
print("a的值为:",a)
demo(a)
print("实参值为:",a)
print("---引用传递---")
a = [1, 2, 3]
print("a的值为:",a)
demo(a)
print("实参值为:",a)
运行结果为:
-------值传递-----
a的值为: 孙悟空
形参值为: 孙悟空孙悟空
实参值为: 孙悟空
-----引用传递-----
a的值为: [1, 2, 3]
形参值为: [1, 2, 3, 1, 2, 3]
实参值为: [1, 2, 3, 1, 2, 3]
原文:https://www.cnblogs.com/xiaobaizzz/p/12210094.html