Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I took a template file in terraform and I want to pass that variable in python, but throws an error each time I use.
{
'Name': 'tag:Name',
'Values': [value]
},
I want to pass the variable using this filter. Can someone help me with this?
you add the letter f before quotes and then use {} to display variables
i = 5
print(f"something {i}")
output: something 5
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I used dictionaries the first time and I can't figure out how to get all first elements of a dictionary. The picture shows an example of my problem. I want to get the brand names, not "brand0, brand1" etc.
thisdict = {
"brand0": ("Ford", "green_car"),
"brand1": ("Audi", "yellow_car"),
"brand2": ("Porsche", "red_car")
}
You can use several aproaches to this problem but the easiest is probably this
firstItems = [value[0] for value in thisdict.values()]
this works the same as
firstItems = []
for value in thisdict.values():
firstItems.append(value[0])
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
In python, I wrote a program to compare two strings.
The coedes are below
d = data.iloc[0]
cmpdate = d['quant_date']
print(cmpdate)
if (cmpdate=='2010-03-18'):
print("=================", dt)
else:
print("xxxxxxxxxxxxx", cmpdate)
the results are
2010-03-18
xxxxxxxxxxxxx 2010-03-18
tow strings are exactly same.
what is the problem?
TIA
Make sure you convert both of the dates to datetime format
and check the result
use to_datetime() function
This works fine
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I have a problem that i cant post something that is already urlencoded
how it should be
dataa = {
client_assertion_type=urn%3Aietf%3Aparams%3Aoauth%3Aclient-assertion-type%3Ajwt-bearer&client_assertion=eyJhbGci.....blahblahblah
}
r = scraper.post(url,headers=headers, data=dataa)
i have tried to make it like
"client_assertion_type": "urn:ietf:params:oauth:client-assertion-type:jwt-bearer&",
But it didnt work, any ideas guys?
You can use urllib.parse.unquote() to decode data:
from urllib.parse import unquote
source = "urn%3Aietf%3Aparams%3Aoauth%3Aclient-assertion-type%3Ajwt-bearer&client_assertion=eyJhbGci"
result = unquote(source)
If you want to decode dict value dynamically, you can rewrite it:
dataa["client_assertion_type"] = unquote(dataa["client_assertion_type"])
Just discovered & in urldecoded string means new line, i used = as :
"client_assertion_type": "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
Hope that will help somebody
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
inputs = []
iterations = int(input())
for x in inputs:
currentInput = input()
inputs.append(currentInput)
print(x)
That code isn't working. It is supposed to make more "currentInput" variables based on "iterations". Thank you soooo, much, as this has been bugging me.
Your code isn't working because it's not right.
Your for loop is going through each element in the list inputs. But inputs is an empty list; you haven't added anything to it so the for loop won't work. You must have meant
for x in range(iterations):
currentInput=input()
inputs.append(currentInput)
print(currentInput)
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I have a task and I did almost of it, but I'm stuck in how i will add keys and values into dictionary from user I think that I have to use input method but I'm not sure .
This code is what i done it shows the max value and key but i add the dictionary i want something like this
x= {'omar':20,'nagy':5}
maxKey= max(x, key=x.get)
maxValue=max(x.values())
print maxKey,maxValue
but the user is the one who enter the key and value
you can do:
count=2
x= {}
while count:
name=input('name:')
value=int(input('value:'))
x[name]=value
count-=1
maxKey= max(x, key=x.get)
maxValue=max(x.values())
print maxKey,maxValue
which will result in: