Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python替换中出现错误。(AttributeError:';tuple';对象没有属性';replace';) 环境_Python_Variables - Fatal编程技术网

python替换中出现错误。(AttributeError:';tuple';对象没有属性';replace';) 环境

python替换中出现错误。(AttributeError:';tuple';对象没有属性';replace';) 环境,python,variables,Python,Variables,我使用的是Python 3,我的操作系统是Windows 7。 我知道有些命令已经从Python2.7过渡到3(我所使用的)了 问题 该变量是临时变量,但如下所示: (((((0, 7), 7), 8), 4), 5) 下面是去掉括号的代码: randy = randy.replace(")", "") randy = randy.replace("(", "") randy = randy.replace(" ", "") 当它尝试执行replace函数时,会抛出一个错误: Traceb

我使用的是Python 3,我的操作系统是Windows 7。 我知道有些命令已经从Python2.7过渡到3(我所使用的)了

问题 该变量是临时变量,但如下所示:

(((((0, 7), 7), 8), 4), 5) 
下面是去掉括号的代码:

randy = randy.replace(")", "")
randy = randy.replace("(", "")
randy = randy.replace(" ", "")
当它尝试执行replace函数时,会抛出一个错误:

Traceback (most recent call last):
File "<string>", line 248, in run_nodebug
File "Criptic.py", line 134, in <module>
randy = randy.replace(")", "")
AttributeError: 'tuple' object has no attribute 'replace'
回溯(最近一次呼叫最后一次):
文件“”,第248行,在run_nodebug中
文件“scriptic.py”,第134行,在
randy=randy.replace(“)”,“”)
AttributeError:“tuple”对象没有属性“replace”
编辑: 以下是所有代码:

#Import string
import string
import random
#Input user data
text = input("Enter your text to be converted: ")

#Test Print
print("-------------------------")
print("Your text is: ",text)




#Break up all the data
data = list(text)

#Lowercase
count = text.count("a")
count1 = text.count("b")
count2 = text.count("c")
count3 = text.count("d")
count4 = text.count("e")
count5 = text.count("f")
count6 = text.count("g")
count7 = text.count("h")
count8 = text.count("i")
count9 = text.count("j")
count10 = text.count("k")
count11 = text.count("l")
count12 = text.count("m")
count13 = text.count("n")
count14 = text.count("o")
count15 = text.count("p")
count16 = text.count("q")
count17 = text.count("r")
count18 = text.count("s")
count19 = text.count("t")
count20 = text.count("u")
count21 = text.count("v")
count22 = text.count("w")
count23 = text.count("x")
count24 = text.count("y")
count25 = text.count("z")
count26 = text.count("A")

#Uppercase
count27 = text.count("B")
count28 = text.count("C")
count29 = text.count("D")
count30 = text.count("E")
count31 = text.count("F")
count32 = text.count("G")
count33 = text.count("H")
count34 = text.count("I")
count35 = text.count("J")
count36 = text.count("K")
count37 = text.count("L")
count38 = text.count("M")
count39 = text.count("N")
count40 = text.count("O")
count41 = text.count("P")
count42 = text.count("Q")
count43 = text.count("R")
count44 = text.count("S")
count45 = text.count("T")
count46 = text.count("U")
count47 = text.count("V")
count48 = text.count("W")
count49 = text.count("X")
count50 = text.count("Y")
count51 = text.count("Z")

#Other Characters
count52 = text.count(" ")
count53 = text.count("?")
count54 = text.count("@")
count55 = text.count("(")
count56 = text.count(")")
count57 = text.count(".")

#Numbers
count58 = text.count("1")
count59 = text.count("2")
count60 = text.count("3")
count61 = text.count("4")
count62 = text.count("5")
count63 = text.count("6")
count64 = text.count("7")
count65 = text.count("8")
count66 = text.count("9")
count67 = text.count("0")

#Counting how many characters in the sentence
finalcount = count + count1 + count2 + count3 + count4 + count5 + count6 + count7 + count8 + count9  + count10  +   count11  + count12  + count13  + count14 + count15 + count16 + count17 + count18 + count19 + count20 + count21 + count22 + count23 + count24 + count25 + count26 + count27 + count28 + count29 + count31 + count32 + count33 + count34 + count35 + count36 + count37 + count38 + count39 + count40 + count41 + count42 + count43 + count44 + count45 + count46 + count47 + count48 + count49 + count50 + count51 + count52 + count53 + count54 + count55 + count56 + count57 + count58 + count59 + count60 + count61 + count62 + count63 + count64 + count65 + count66 + count67

#Final count of Characters
print("       Chars: ",finalcount)
print("-------------------------")





char = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$%^&*()?_+-=1234567890           "
charnum = 74 + 11
list(char)

randy = 0
num = 0
while num < finalcount:
    rand = random.randrange(1,9)
    randy = randy,rand
    finalcount = finalcount - 1
    if rand == 1:
    print(text[finalcount],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],",")
if rand == 2:
    print(char[random.randrange(0,charnum)],text[finalcount],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],",")
if rand == 3:
    print(char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],text[finalcount],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],",")
if rand == 4:
    print(char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],text[finalcount],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],",")
if rand == 5:
    print(char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],text[finalcount],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],",")
if rand == 6:
    print(char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],text[finalcount],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],",")
if rand == 7:
    print(char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],text[finalcount],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],",")
if rand == 8:
    print(char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],text[finalcount],char[random.randrange(0,charnum)],",")
if rand == 9:
   print(char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],char[random.randrange(0,charnum)],text[finalcount],",")


randy = randy.replace(")", "")
randy = randy.replace("(", "")
randy = randy.replace(" ", "")

print("-------------------------")
print("::::::::Completed::::::::")
print("-------------------------")
print(randy)
print("-This is your code unlock key. Without this code it will not decript!!!! ")
print("-------------------------")
#导入字符串
导入字符串
随机输入
#输入用户数据
text=输入(“输入要转换的文本:”)
#试印
打印(“---------------------------”)
打印(“您的文本为:”,文本)
#分解所有数据
数据=列表(文本)
#小写的
计数=文本。计数(“a”)
count1=文本计数(“b”)
count2=text.count(“c”)
count3=text.count(“d”)
count4=text.count(“e”)
count5=文本计数(“f”)
count6=文本计数(“g”)
count7=text.count(“h”)
count8=text.count(“i”)
count9=text.count(“j”)
count10=text.count(“k”)
count11=文本计数(“l”)
count12=text.count(“m”)
count13=文本计数(“n”)
count14=文本计数(“o”)
count15=text.count(“p”)
count16=text.count(“q”)
count17=文本计数(“r”)
count18=text.count(“s”)
count19=文本计数(“t”)
count20=文本计数(“u”)
count21=文本计数(“v”)
count22=text.count(“w”)
count23=text.count(“x”)
count24=text.count(“y”)
count25=text.count(“z”)
count26=文本计数(“A”)
#大写字母
count27=文本计数(“B”)
count28=text.count(“C”)
count29=文本计数(“D”)
count30=text.count(“E”)
count31=文本计数(“F”)
count32=text.count(“G”)
count33=text.count(“H”)
count34=text.count(“I”)
count35=text.count(“J”)
count36=text.count(“K”)
count37=文本计数(“L”)
count38=text.count(“M”)
count39=text.count(“N”)
count40=text.count(“O”)
count41=text.count(“P”)
count42=text.count(“Q”)
count43=文本计数(“R”)
count44=text.count(“S”)
count45=text.count(“T”)
count46=文本计数(“U”)
count47=文本计数(“V”)
count48=text.count(“W”)
count49=text.count(“X”)
count50=text.count(“Y”)
count51=text.count(“Z”)
#其他字符
count52=文本。计数(“”)
count53=文本。计数(“?”)
count54=文本计数(“@”)
count55=文本。计数(“”)
count56=text.count(“)”)
count57=text.count(“.”)
#数字
count58=text.count(“1”)
count59=text.count(“2”)
count60=text.count(“3”)
count61=text.count(“4”)
count62=文本计数(“5”)
count63=text.count(“6”)
count64=text.count(“7”)
count65=text.count(“8”)
count66=text.count(“9”)
count67=text.count(“0”)
#计算句子中有多少个字符
最终计数=计数+计数1+计数2+计数3+计数4+计数5+计数6+计数7+计数8+计数9+计数10+计数11+计数12+计数13+计数14+计数15+计数16+计数17+计数18+计数19+计数20+计数21+计数22+计数23+计数24+计数25+计数26+计数27+计数28+计数29+计数31+计数32+计数33+计数34+count35+count36+count37+count38+count39+count40+count41+count42+count43+count44+count45+count46+count47+count48+count49+count50+count51+count52+count53+count54+count55+count56+count57+count58+count59+count60+count61+count62+count63+count64+count65+count66+count67
#最后字符数
打印(“字符:,最终计数)
打印(“---------------------------”)
char=“abcdefghijklmnopqrstuvwxyzabefghijklmnopqrstuvxyz!@$%^&*()?+-=1234567890”
charnum=74+11
列表(字符)
兰迪=0
num=0
当num result = " ".join(str(x) for x in randy)
randy = randy,rand
randy = []
num = 0
while num < finalcount:
    rand = random.randrange(1,9)
    randy.append(rand)
randy = ",".join(randy)
exam_st_date = (11, 12, 2014)
# Sample Output : The examination will start from : 11 / 12 / 2014

newtup = str(exam_st_date).replace(',', ' /')


print(newtup)
import string
name = "(((((0, 7), 7), 8), 4), 5)"
table = string.maketrans( '', '', )
print name.translate(table,"()")