[Python] Two or two combinations in the List (suitable for TXT file data transition coordinates)

tags: Python  list  

source code

list = [1, 2, 3, 4, 5, 6, 7]
p1 = []
for i in range(0,len(list)-1,2):
        p2 = []         
        p2.append(list[i])
        p2.append(list[i+1])
        p1.append(p2)
print(p1)

result

[[1, 2], [3, 4], [5, 6]]

Intelligent Recommendation

Python list element two or two combinations batch drawing part of the dependencies

Draw the selected variables for two or two combinations to draw a two -dimensional part dependent diagram...

Python - a line-by-line stitching two TXT files, the list is written to the TXT file, remove the part of each row in TXT, separated and / spaced

Demand is:Need to put two TXT files on two lines, put it in a new TXT     Demand is:Write the list to the TXT file   demand:TXT is a row of folder directories and want to extract the fi...

Python writes the content of the .txt file to Excel (suitable for data batch processing)

The distress of science and engineering graduate students (data batch processing) Every time the instructor asks us to do a project, he will give hundreds or even thousands of data, and then go inside...

Python save two-dimensional array to txt file

A very cumbersome and rude method, python belongs to the entry-level level, so please backup it first, and update it if there is a better method   ⭐np.savetxt() method write...

Python implements two TXT file content comparison

Two TXT files are guided from the database, with the primary key. Looking for a file contrast from the Internet: MD5: Use the two files using MD5, if the MD5 of the two files illustrates the same cont...

More Recommendation

The Python script handles the TXT file and processes the JSON data, and the core is consistent with the two file data.

Actual work handling data packet format, as well as data content to do data, check scripts. Before it is a direct consumption Kafka to read data, a Topic puts multiple provinces, distinguishing betwee...

Python one-dimensional list and two-dimensional list transition

One-dimensional list is converted to a two-dimensional list Two-dimensional lists are transformed into one-dimensional list...

Python grid displays xy coordinates in txt file

1.txt file content 2.python partial code 3. Execution results...

Two two combinations of Python List elements, multiple List elements, ie Cartesi

Problem: I want to have two two combinations of elements in a list, various combinations of multiple List elements. Solve: Utilizationitertools.product(*iterables, repeat=2)Cartikale can Description: ...

Convert the TXT file and convert to a function of a two-dimensional list

Convert the TXT file and convert to a function of a two-dimensional list...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top