美文网首页
装饰器demo

装饰器demo

作者: tutu_tutu | 来源:发表于2018-11-14 21:12 被阅读0次

    def all_a(func):
    def spl(file_name):
    data = func(file_name)
    k = []
    for i in data:
    m = i.split('\n')
    m = m[0]
    k.append(m)
    return k
    return spl

    @all_a # all_a(openfile)
    def openfile(file_name):
    file = open(file_name, 'r')
    a = file.readlines()
    file.close()
    return a

    a = openfile('k.txt')
    print(a)
    b = openfile('l.txt')
    print(b)
    print(dict(zip(a, b)))

    相关文章

      网友评论

          本文标题:装饰器demo

          本文链接:https://www.haomeiwen.com/subject/vbssfqtx.html