Don';我不知道如何去掉列表中的这些{}(python2.7)

Don';我不知道如何去掉列表中的这些{}(python2.7),python,list,brackets,Python,List,Brackets,我试着将列表转换成字符串,但我似乎无法摆脱括号: import Tkinter import random window = Tkinter.Tk() window.geometry("250x150") window.title("Backstory_Generator") window.config(bg="black") Race=Tkinter.Entry(window, bd=10)#gui stuff Racee=Tkinter.Label(window,text="Race")

我试着将列表转换成字符串,但我似乎无法摆脱括号:

import Tkinter
import random
window = Tkinter.Tk()
window.geometry("250x150")
window.title("Backstory_Generator")
window.config(bg="black")

Race=Tkinter.Entry(window, bd=10)#gui stuff
Racee=Tkinter.Label(window,text="Race")
Racee.config(bg="Black", fg="White")
Race.config(bg="Grey")


Class=Tkinter.Label(window,text="Class")#gui stuff
Clas=Tkinter.Entry(window,bd=10)
Class.config(bg="Black", fg="White")
Clas.config(bg="Grey")

def Select():
    text1 = random.randint(0,len(pb1)-1)
    text2=random.randint(0,len(pb2)-1)#picks random number for word
    text3=random.randint(0,len(pb3)-1)
    text4 = random.randint(0,len(pb4)-1)
    RaceChosen = Race.get()#retreus what entered
    ClassChosen = Clas.get()
    Result = Tkinter.Tk()#new window
    Result.title("Result")
    Result.config(bg="Black")
    lol = "You are a",RaceChosen,"who has chosen to path of the",ClassChosen,"\n","you are " + pb1[text1] + " and craving for " + pb2[text2] + " ,You also are extremely " + pb3[text3] + " around others","\n","due to your " + pb4[text4] + " tendancies"
    Line1 = Tkinter.Label(Result, text=lol)#outputs random thing
    Line1.config(font=("Courier",15, "bold"))
    Line1.config(bg="Black", fg="White", height = 10)
    Line1.pack()
    Result.geometry=("1000x250")
    Result.mainloop()

Generate = Tkinter.Button(window, text="Generate", command=Select)

Racee.pack()
Race.pack()
Class.pack()
Clas.pack()
Generate.pack()


window.mainloop()
正如您将看到的,括号创建了一个奇怪的外观,我似乎无法摆脱。我知道这个问题已经被问了很多次,但是将列表转换成字符串并使用.join(map)对我来说不起作用。 有什么建议吗?我遗漏了这些列表,因为它们包含一些明确的材料,所以是的:P

看看这行:

lol = "You are a",RaceChosen,"who has chosen to path of the",ClassChosen,"\n","you are " + pb1[text1] + " and craving for " + pb2[text2] + " ,You also are extremely " + pb3[text3] + " around others","\n","due to your " + pb4[text4] + " tendancies"
您创建的是元组而不是字符串。

请看这一行:

lol = "You are a",RaceChosen,"who has chosen to path of the",ClassChosen,"\n","you are " + pb1[text1] + " and craving for " + pb2[text2] + " ,You also are extremely " + pb3[text3] + " around others","\n","due to your " + pb4[text4] + " tendancies"

您创建的是元组而不是字符串。

您可以通过使用字符串插值来解决此问题<代码>“您是一个%s,选择了%s的路径\n您是(等)”%(RaceSelected,ClassSelected,…)我将如何更改它?对不起,我有点新,你能给我一个代码示例吗,比如我如何将%定义为RaceSelected或ClassSelected?我遇到了这个错误:Tkinter回调回溯中出现异常(最近一次调用):文件“/usr/lib/python2.7/lib tk/Tkinter.py”,第1540行,在call return self.func(*args)文件中“/home/cam/Documents/Python files/Character Generator.py”,第34行,在Select lol=“你们是一个选择了%s路径的%s人\n你们是%s并且渴望得到%s,你们在其他人周围也是非常%s的”,“\n”,“由于你们的%s倾向”%(RaceSelected,ClassSelected,pb1[text1],pb2[text2],pb3[text3],pb4[text4])TypeError:并不是所有的参数在字符串格式化过程中都被转换成这样:lol=“你们是一个选择了%s路径的%s人\n你们是%s并且渴望得到%s,你们也是%s周围的人”,“\n”,“由于你们的%s倾向”%(RaceSelected,ClassSelected,pb1[text1],pb2[text2],pb3[text3],pb4[text4])您可以通过使用字符串插值来修复此问题。
“您是一个%s,已选择了%s的路径\n您是(等)”%(RaceSelected,ClassSelected,…)
我该如何更改它?对不起,我有点新。你能给我一个代码示例吗,比如我该如何将%定义为RaceSelected,或ClassSelected?我遇到了这个错误:Tkinter回调回溯异常(最近一次调用上次):File“/usr/lib/python2.7/lib tk/Tkinter.py”,第1540行,在call return self.func(*args)File中/home/cam/Documents/Python files/Character Generator.py”,第34行,在Select lol=“您是一个选择了%s路径的%s人\n您是%s并且渴望得到%s,您也非常喜欢%s周围的其他人”,“\n”,“由于您的%s倾向”%(RaceSelected,ClassSelected,pb1[text1],pb2[text2],pb3[text3],pb4[text4])TypeError:并不是所有的参数在字符串格式化过程中都被转换成这样:lol=“你们是一个选择了%s路径的%s人\n你们是%s并且渴望得到%s,你们也是%s周围的人”,“\n”,“由于你们的%s倾向”%(RaceSelected,ClassSelected,pb1[text1],pb2[text2],pb3[text3],pb4[text4])