Python简介,导致函数打印为true

时间:2014-05-25 22:28:23

标签: python function return

这是我第一次使用Python,我有一个问题需要解决,下面是一个在输入内容时输出true的方法。我不明白这里发生了什么,所以有人试图解释这里发生了什么,以及什么会导致某些东西打印出来。这种方法有没有特定的名称?某种策略在这里发生?

基本上我在寻找

  • 什么会导致打印成真?
  • 为什么使用关键字?
  • 打印为true

在此先感谢,请记住我是Python的初学者,所以请尝试而不是讨厌。

quam, quum="",""
class char:
    def __init__(self, *x): pass
    def __add__(self, x):
        try:
                  globals()['quum'] += x
        except:
                  return True
for i in [102, 114, 111, 109, 32, 122, 108, 105, 98, 32, 105, 109, 112, 111, 114, 116, 32, 100, 101, 99, 111, 109, 112, 114, 101, 115, 115, 32, 97, 115, 32, 121, 10, 102, 114, 111, 109, 32, 98, 105, 110, 97, 115, 99, 105, 105, 32, 105, 109, 112, 111, 114, 116, 32, 117, 110, 104, 101, 120, 108, 105, 102, 121, 32, 97, 115, 32, 117]:
    quam = char() + chr(i)

if char() + 100: exec(quum)
else: exec(quam)
c = 204112890334875644936547550670918483174507745028227181355093277104005052842989650193062069077845326 42489437847494411971123810887
hi = eval(y(u(hex(c)[1+1:1-1-1])))
print hi(raw_input("Your input:"))

1 个答案:

答案 0 :(得分:4)

这显然是一些混淆代码。您可以通过开始打印您不理解的所有内容来支持它,例如以quum开头,这是一个填充代码并使用exec()评估的字符串:

>>> print quum
from zlib import decompress as y
from binascii import unhexlify as u

现在你知道什么是yu

>>> u
<built-in function unhexlify>
>>> y
<built-in function decompress>

现在以某种方式处理数字c

>>> hex(c)
'0x789ccb49cc4d4a4954a8b0aab0b5552fc9c82c8e07a2e2fcdcd4f8f2d4cca294f89cfcfcecccbcf4f882ca928cfc3c7500ab851247L'
>>> hex(c)[1+1:1-1-1]
'789ccb49cc4d4a4954a8b0aab0b5552fc9c82c8e07a2e2fcdcd4f8f2d4cca294f89cfcfcecccbcf4f882ca928cfc3c7500ab851247'

看起来像某些字节的十六进制表示,不是吗?

>>> u(hex(c)[1+1:1-1-1])
'x\x9c\xcbI\xccMJIT\xa8\xb0\xaa\xb0\xb5U/\xc9\xc8,\x8e\x07\xa2\xe2\xfc\xdc\xd4\xf8\xf2\xd4\xcc\xa2\x94\xf8\x9c\xfc\xfc\xec\xcc\xbc\xf4\xf8\x82\xca\x92\x8c\xfc<u\x00\xab\x85\x12G'

让我们解压它们!

>>> y(u(hex(c)[1+1:1-1-1]))
"lambda x:x=='this_is_some_weird_looking_python'"

是的,这是一个字符串!

>>> hi = eval(y(u(hex(c)[1+1:1-1-1])))
>>> hi
<function <lambda> at 0x1dde938>

现在这只是一个lambda函数的定义,如果你输入this_is_some_weird_looking_python

,它会返回true 简单,呵呵?