Home > database >  I need put a variable inside data for request - Very simple question
I need put a variable inside data for request - Very simple question

Time:10-17

I need put credentials inside data variable. But, i need start this with ', Because if not, 'true' would be considered the call to a variable, but it's not.

As it stands, of course it doesn't call the credentials variable, but I want a way to do that. I've already tested f' and .format, but without success.

How I do?

credentials = str(inputtxt.get())   str(inputtxt2.get())
    
data = '{"name":credentials, "private":true}' 

Thanks in advance!

CodePudding user response:

I'm not exactly sure what you're asking but I when making a dict you don't use quotes it's just:

data = {"name":credentials, "private":true}

CodePudding user response:

thank you all for the help, but I did it! Maybe not in the best way, but I did it!

Here's my solution in case anyone needs it:

data = '{"name":"replace", "private":true}'
    
data = data.replace('replace', credentials)

Thanks!

  • Related