Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Python3 - PDF PAGES SEPARATION
#python 3.5.2 import json pdf_sequence_dict = {'document-page1.pdf': (1, 1), 'document-page10.pdf':(10, 0), 'document-page2.pdf': (2, 0), 'document-page3.pdf': (3, 1), 'document-page4.pdf': (4, 0), 'document-page5.pdf': (5, 1), 'document-page6.pdf': (6, 0), 'document-page7.pdf': (7, 1), 'document-page8.pdf': (8, 0), 'document-page9.pdf': (9, 1) } pdf_sequence_list = sorted([(v , k) for k , v in pdf_sequence_dict.items()], key=lambda tup:tup[0][0]); final_list = [[pdf_sequence_list[i][1], pdf_sequence_list[i+1][1]] for i in range(0, len(pdf_sequence_list), 2)]; # PRETTY PRINTING LIST print(json.dumps(final_list, indent=4));
run
|
edit
|
history
|
help
0
147
Name
teste
public,protec,pvt
problem
Python
static
1
Dictionary example
Hello. Py