'''
y=2*x+1
x=3
y->7
x=3
y->7
'''
# def test(x):
# '''
# 2*x+1
# :param x:整形数字
# :return: 返回计算结果
# '''
# y=2*x+1
# return y
#
# def test():
# '''
# 2*x+1
# :param x:整形数字
# :return: 返回计算结果
# '''
# x=3
# y=2*x+1
# return y
# a=test()
# print(a)

#过程:就是没有返回值的函数

# def test01():
# msg = 'test01'
# print(msg)
#
#
# def test02():
# msg = 'test02'
# print(msg)
# return msg
#
# def test03():
# msg = 'test03'
# print(msg)
# return 1,2,3,4,'a',['alex'],{'name':'alex'},None
#
# def test04():
# msg = 'test03'
# print(msg)
# return {'name':'alex'}
# t1=test01()
# t2=test02()
# t3=test03()
# t4=test04()
# print(t1)
# print(t2)
# print(t3)
# print(t4)

# def calc(x,y): #x=2,y=3
# res=x**y
# return x
# return y
# res=calc(2,3)
# # print(x)
# # print(y)
# print(res)
# # a=10
# # b=10
# # calc(a,b)

# def test(x,y,z):#x=1,y=2,z=3
# print(x)
# print(y)
# print(z)

#位置参数,必须一一对应,缺一不行多一也不行
# test(1,2,3)

#关键字参数,无须一一对应,缺一不行多一也不行
# test(y=1,x=3,z=4)

#位置参数必须在关键字参数左边
# test(1,y=2,3)#报错
# test(1,3,y=2)#报错
# test(1,3,z=2)
# test(1,3,z=2,y=4)#报错
# test(z=2,1,3)#报错

# def handle(x,type='mysql'):
# print(x)
# print(type)
# handle('hello')
# handle('hello',type='sqlite')
# handle('hello','sqlite')

# def install(func1=False,func2=True,func3=True):
# pass

#参数组:**字典 *列表
def test(x,*args):
print(x)
print(args)

# test(1)
# test(1,2,3,4,5)
# test(1,{'name':'alex'})
# test(1,['x','y','z'])
# test(1,*['x','y','z'])
# test(1,*('x','y','z'))

# def test(x,**kwargs):
# print(x)
# print(kwargs)
# test(1,y=2,z=3)
# test(1,1,2,2,2,2,2,y=2,z=3)
# test(1,y=2,z=3,z=3)#会报错 :一个参数不能传两个值

def test(x,*args,**kwargs):
print(x)
print(args,args[-1])
print(kwargs,kwargs.get('y'))
# test(1,1,2,1,1,11,1,x=1,y=2,z=3) #报错
# test(1,1,2,1,1,11,1,y=2,z=3)

# test(1,*[1,2,3],**{'y':1})

Pyhton学习——Day4的更多相关文章

  1. Pyhton学习——Day26

    #多态:多态指的是一类事物有多种形态# import abc# class Animal(metaclass = abc.ABCMeta):# 同一类事物:动物# @abc.abstractclass ...

  2. pyhton 学习

    官方学习文档 https://docs.python.org/3/tutorial/

  3. python全栈学习--day4

    列表 说明:列表是python中的基础数据类型之一,它是以[]括起来,每个元素以逗号隔开,而且他里面可以存放各种数据类型比如:   1 li = ['alex',123,Ture,(1,2,3,'wu ...

  4. 20190320_head first pyhton学习笔记之构建发布

    1.把代码nester.py放入文件夹nester中,在文件夹中再新建一个setup.py文件,文件内容如下: from distutils.core import setup setup( name ...

  5. python学习day4软件目录结构规范

    为什么要设计好目录结构? 参考:http://www.cnblogs.com/alex3714/articles/5765046.html "设计项目目录结构",就和"代 ...

  6. 自动化测试学习day4

    主要学习内容:修改文件.集合.函数.模块 修改文件两种方法 修改文件方法一(缺点:代码繁琐,一次性将文件读出,文件过大可能会卡住) with open('geci', 'a+', encoding=' ...

  7. Python学习-day4

    学习装饰器,首先听haifeng老师讲解了一下准备知识. 1.函数即变量 2.高阶函数+嵌套函数==>装饰器 装饰器的作用是在,1)不改变源代码,2)不改变原函数的调用方式的前提下为函数增加新的 ...

  8. Pyhton学习——Day2

    Python开发IDE(工具)Pycharm.eclipse1.循环while 条件 #循环体 #条件为真则执行 #条件为假则执行break用于退出所有循环continue用于退出当前循环 2.Pyc ...

  9. Pyhton学习——Day28

    #上下文协议:文件操作时使用with执行# with open('a.txt','w',encoding='utf-8') as f1:# with语句,为了让一个对象兼容with语句,必须在这个对象 ...

随机推荐

  1. JS 1000以内的水仙花数 (三位数 各个数字的立方和等于本身 例如 1*1*1 + 5*5*5 + 7*7*7 = 157)

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  2. lsync 负载实现代码双向同步

    参考文件: https://www.zyku.net/centos/1713.html 检查错误命令: lsyncd -pidfile /tmp/lsyncd.pid  /etc/lsyncd.con ...

  3. [BZOJ1999] 树网的核 [数据加强版] (树的直径)

    传送门 如果只是想验证算法正确性这里是洛谷数据未加强版 Description 设T=(V, E, W) 是一个无圈且连通的无向图(也称为无根树),每条边带有正整数的权,我们称T为树网(treenet ...

  4. 中国电信线CTF线下选拨writeup

    [盟军密码|30分] 二战时盟军截获德军一段密码,密文为:0000011000000000101010110111000011000111100011110001001100111000111001( ...

  5. maven 依赖的传递性

    1.如图我们有三个项目,项目Age,项目Bge,项目Cge 2.我们使Age项目依赖到Bge项目,Bge项目依赖到Cge项目 Age项目和Bge项目分别执行命令:mvn install  打包*.ja ...

  6. CodeForcesGym 100548G The Problem to Slow Down You

    The Problem to Slow Down You Time Limit: 20000ms Memory Limit: 524288KB This problem will be judged ...

  7. 2015 Multi-University Training Contest 6 hdu 5357 Easy Sequence

    Easy Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)T ...

  8. Apach配置本地域名

    分三步: 一,开启虚拟域名设置,在路径中找到(apache\apache2.4.9\conf)httpd.conf 配置文件, 去掉 " Include conf/extra/httpd-v ...

  9. K - The Unique MST

    K - The Unique MST #include<iostream> #include<cstdio> #include<cstring> #include& ...

  10. HDU 4767

    昨晚苦恼了一晚,因为即将大三了,必须要准备实习什么的事了.一般都会去公司实习吧,但是看看自己的简历,实在拿不出手,因为大一大二都在搞ACM(虽然真正搞的只有大二一年),但却没有什么成绩,又不愿意做项目 ...