python_趣味函数式编程

# Author : XueFeng
"""
1. 面向对象     华山派     类       class
2. 面向过程     少林派     过程      def
3. 函数式编程    逍遥派     函数      def
"""

# 函数与过程的简单讲解
# 函数
def func1():
    """testing"""
    print("In the func1")
    return 0


# 过程
def func2():
    """testing2"""
    print('in the func2')


x = func1()
func2()
print('from func1 return %s' % x)


print('from func2 return %s' % y)



# 函数调用的简单讲解
import time


def logger():
    time_format = "%Y-%m-%d %X"		# 时间格式 年-月-日 具体时间
    current_time = time.strftime(time_format)	#获取当前时间
    with open('.//test1.txt', 'a+') as fp:		#已追加写的方式打开文件
        fp.write('%s end action\n' % current_time)


def test2():
    print('in the test1')
    logger()		#调用函数


def test3():
    print('in the test1')
    logger()


def test4():
    print('in the test1')
    logger()


test2()
test3()
test4()


# 关于函数返回值的问题详解
def test_1():
    print('In the test1')


def test_2():
    print('In the test1')
    return 0


def test_3():
    print('In the test1')
    return 1, 'hello', ['jim', 1], {'jim': 23}


x = test_1()
y = test_2()
z = test_3()
print(x)
print(y)
print(z)


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值