python
网站首页 |   



  • python 1行代码1个程序风格之:(高级卡密验证的安全写法)
  • 发布: 江湖程序员 来源: 本站原创 时间: 2014/11/25 12:00:01
    (4474) 点赞: (147) 标签: 原创代码


    1行代码1个程序
      python 1行代码1个程序,代码可以连成一行,且代码中不包含分号、for、while、if、else等常规语法,取而代之的是lambda、and、or等,使之更加晦涩难以解读,虽有悖于pep08规范,但也是别具一格!用于高级卡密验证的安全写法非常稳妥。
    #一行代码一个程序风格写法(安全写法):
    print(
        (lambda a:(
            a == ['x', 'y', 'z', 'a', 'b', 'c', '1', '2', '3', '4', '5', '6', '7', 'd', 'e', 'f', 'g']
             and '执行功能' or '抱歉,未激活' and a))(
            (lambda a, b = 0, c = lambda a, b, c, l = list():(
                len(a) > b and (
                    hasattr(a[b], '__iter__') and not isinstance(a[b], (str, bytes)) and c(a[b], 0, c) or l.append(a[b]) or l
                ) and c(a, b + 1, c) or l[len(a)]
            ):c(a, b, c))([('x', ['y', 'z']), 'a', ['b', 'c', (['1', '2'], '3')], ['4', ('5', '6', ('7', ['d', 'e', 'f']))], 'g'])
        )
    )
    你能在不运行代码的前提下推导出这一行代码输出的结果吗?

    作者:江湖程序员 (python帮助网)
    转载请注明出处: www.pythonhelp.cn


    ---= 已经到底 =---