TJ20240606

# 闭包
# def hello():
#     username='刘阳'
#     def world():
#         return username
#     return world

# def hello(username):
#     def world(status):
#         return username+status
#     return world

# world = hello()
# print(world())



# from functools import reduce

# sorted
# lists = [2,5,2,4,7]
# print(sorted(lists,reverse=True))

# filter
# def get_data(x):
#     return x%2==0
# print(filter(get_data(range(1,101))))

# reduce 累加累乘
# def get_data(x,y):
#     return x+y
# # 过程
# # x=1 y=2
# # x=2 y=3
# # x=6 y=4
#
# print(reduce(get_data,(range(1,101))))

# map 列表输入输出1
# def get_data(x):
#     return x**3
#
# print(list(map(get_data,[1,2,3])))

# reversed 倒序
# lists=[1,3,2,5,2]
# print(list(reversed(lists)))

# max min 最值

# 匿名函数 一次性调用
# get_data = lambda x:x**3
# print(get_data(3))
# print(list(map(get_data,[1,2,3])))
# get_data = lambda x,y:x+y
# print(reduce(get_data,(range(1,101))))

# 类和实例
# class Student(object):
#     # 类属性
#     province = '广东'
#     def __init__(self,name):
#         # 实例属性
#         self.name = name
#     # 实例方法
#     def say(self):
#         print('{}说我今天要跑步'.format(self.name))
#     # 类方法
#     @classmethod
#     def hello(cls):
#         print('hello world')
#     # 静态方法
#     @staticmethod
#     def world():
#         print('你好')

# 类的实例化
# stu1 = Student('张三')
# stu2 = Student('李四')

# print(stu1.name,stu1.province)
# print(stu2.name,stu2.province)

# print(Student.province)

# print(stu1.say())

# Student.hello()
# Student.world()
# stu1.hello()
# stu1.world()
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值