python - sort a field in ascending order and delete the first and last number -
I have data that looks like the following:
a 10,5 , 3, 66,50b, 2,10,1,88,5,8,9, C, 4,60,10,39,55,22 de 1,604,3,503,235,45,60,7 e 20,59,33,2 , 6, 45,36,34,22 I want to sort the data in the ascending order in the second column
a 3,5,10 , 50,66 B 1,2,5,8,9,10,88 C4,10,22,39,55,60 .... .... Then The Smallest and the Largest Value So in this way:
one 5,10,50 b 2,5, 8 9, 10 c 10,22,39,55 .... .... Any help would be appreciated!
r ') in the form of> fine, open (' result.txt ',' w '): for the row in the wings: f0, f1 = line.split () fout ('% s \ t% S \ n '% (f0,', '. (Sorted (f1.split (', '), key = int) [1: -1]))) The body of the loop can be unexpected in this way:
f0, f1 = line.split () # field split on white space = f1.split (',') # comma The second segment divided on = sorted (item, key = intestine) # or item. # Objects as item (key = int) # items as item items [1: -1] # ccv line as the # get rid of the first and last items = '% s \ t% s \ n'% (f0, F1) Re-gather line fout.write (line) # write it
Comments
Post a Comment