AttributeError:'tuple'对象没有属性'replace'

时间:2017-08-17 03:45:46

标签: python printing urllib2 python-import

我发现这段代码用于描述PHP,但我猜它和旧版本,并且每次出现不同的错误。

将发布原文。

import urllib
import re

php = urllib.urlopen("http://pastebin.com/raw.php?i=wVs8w44v").read()

# Slight modification below so that we don't escape $
z26 = "jmiO@sxhFnD>J\r/u+RcHz3}g\nd{^8 ?eVwl_T\\\t|N5q)LobU]40!p%,rC-97k<'y=W:P$1BI&S6\"E(K`Y~.Q;f[v2a#X*ZAGtM"

# Decode all $z26[...] strings
for i in range(len(z26)):
    php = php.replace("$z26[" + str(i) + "]", "\"" + z26[i] + "\"")

# Concatenate decoded strings
php = php.replace("\".\"", "")

# Replace all $GLOBALS[...]
globals = {}
for m in re.finditer("\$GLOBALS\['(?P<key>\w+?)'\] = \"(?P<value>.*?)\";", php):
    globals[m.group("key")] = m.group("value")
php = re.sub(" \$GLOBALS\['(?P<key>\w+?)'\] = \"(?P<value>.*?)\";", "", php)
for key in globals.keys():
    php = php.replace("$GLOBALS['" + key + "']", globals[key])

print php

嗯,我做了一些修改,但在跑步时仍有问题。

如果有人可以发光!

0 个答案:

没有答案