0
点赞
收藏
分享

微信扫一扫

Python入门--函数参数的定义,以及print输出格式的设置

古得曼_63b6 2022-02-26 阅读 52
python
#函数的参数定义
#函数定义时,给形参设置默认值,只有与默认值不符的时候,才需要传递实参
######################33

def fun(a,b=10):#给形参设置默认值
    print(a,b)

fun(100)#只穿一个参数,b采用默认值  100 10
fun(20,30)#30将默认值替换,   20 30

print('hello')#默认换行
print('world')


'''print()#按住ctrl后点击print
def print(self, *args, sep=' ', end='\n', file=None): # k
默认end='\n'换行
'''
print('hello',end='\t')
print('world')
print('hello',end='')
print('world')
print('hello',end=' ')
print('world')
举报

相关推荐

0 条评论