Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
Input_data=[{'filename':'file_A','start_page':1,'end_page':3,'angle':90},{'filename':'file_A','start_page':6,'end_page':8,'angle':270},{'filename':'file_B','start_page':2,'end_page':3,'angle':90},{'filename':'file_B','start_page':5,'end_page':5,'angle':270}]
output=[{'filename':'file_A','page':1,'angle':90},
{'filename':'file_A','page':2,'angle':90},{'filename':'file_A','page':3,'angle':90},{'filename':'file_A','page':6,'angle':270},{'filename':'file_A','page':7,'angle':270},
{'filename':'file_A','page':8,'angle':270},{'filename':'file_B','page':2,'angle':90},
{'filename':'file_B','page':3,'angle':90},{'filename':'file_B','page':5,'angle':270}]
}
If I understood correctly, you want to do:
output = []
for d in Input_data:
for i in range(d["start_page"], d["end_page"] + 1):
output.append({'filename':d["filename"], 'page':i, 'angle':d["angle"]})
print(output)
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 days ago.
Improve this question
The problem in picture
kaka=dayData['Name']
date=datetime.strptime(kaka, '%d-%m-%Y')
date=date.strftime('%Y-%m-%d ')
#print(date)
sSplit = row['StartTime'].split("T")
eSplit = row['EndTime'].split("T")
sSplit[0]=date
eSplit[0]=date
#print(sSplit)
#print(eSplit)
start_str=' '.join(map(str,sSplit))
end_str=' '.join(map(str,eSplit))
I need to change the date of the last record in database as shown in picture.
..................................................
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 months ago.
Improve this question
How do I write a Python program to print the pattern?
543210
432105
321054
210543
054321
543210
You can do it by something like this:
a = "543210"
print(a)
for i in range(6):
a = a + (a[0])
a = a[1:]
print(a)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 11 months ago.
Improve this question
use python 3.6
this json: [["10000000000"], ["12000000000"]]
i want get like result like
"data": {"calleeInfo": [{"phone": "10000000000",},{"phone": "12000000000",}]}
By list generation
temp = [["10000000000"], ["12000000000"]]
value = [{"phone": i[0]} for i in temp]
result = {"data": {"calleeInfo": value}}
print(result)
Output
{'data': {'calleeInfo': [{'phone': '10000000000'}, {'phone': '12000000000'}]}}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
these items are in a list
SF-04-08-010-MD01,
AHU-VVIP-02-003-MD03,
AHU-02-17-019-DPS03,
AHU-T3-01-PL-TS01,
EF-03-32-108-MD01,
AHU-02-16-019-MD01,
AHU-T3-01-003-MD01,
SF-04-08-010-MD01,
AHU-VVIP-02-003-MD03,
so i want a new list which should be like
SF-04-08
AHU-VVIP
AHU-02-17
AHU-T3-01
EF-03-32
AHU-02-16
AHU-T3-01
SF-04-08
AHU-VVIP-02
using python??
you can use strip like:
data = ['SF-04-08-010-MD01',
'AHU-VVIP-02-003-MD03',
'AHU-02-17-019-DPS03'
]
for item in data:
print ('-'.join(item.split('-')[:3]))
output:
SF-04-08
AHU-VVIP-02
AHU-02-17
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
need to extract projectID and my final output is to be 1868117666669.
'{
"code":"ok",
"job":{
"config":{
"progress":{
"message":"Reading 2014-03-03__12-57-01-PM.xml",
"percent":107,
"maxmemory":954,
"memory":667
},
"projectID":1868117666669,
# other stuff
}
}
}'
You can try
>>> a = '{"code":"ok","job":{"config":{"progress":{"message":"Reading 2014-03-03__12-57-01-PM.xml","percent":107, "maxmemory":954,"memory":667},"projectID":1868117666669}}}'
>>> json.loads(a)['job']['config']['projectID']
1868117666669