2017-06-30 24 views
-1

私は大きな多次元配列を持っていました。この配列に各リストを印刷したかったのです。ループしてみましたが、代わりに各リストの各リスト項目を別々に表示します。リスト全体を一緒に印刷したいと思います。これはどうすればいいですか?ありがとうございました。 これは私の現在の試みです:多次元配列pythonで各リストを印刷するには?

import math 
from collections import Counter 

with open('OOR LIST VERTICAL.txt') as input_file: 
    long_list = [line.strip() for line in input_file] 

C = Counter(long_list) 
print([ [k,]*v for k,v in C.items()]) 

for each in long_list: 
    print(each) 

これは私の多次元配列は、次のようになります。

[['2281', '2281', '2281', '2281', '2281', '2281'], ['2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095'], ['2153', '2153', '2153', '2153', '2153', '2153', '2153', '2153', '2153', '2153', '2153', '2153', '2153', '2153', '2153', '2153', '2153', '2153', '2153'], ['3207', '3207', '3207'], ['2120', '2120', '2120', '2120', '2120', '2120', '2120', '2120', '2120', '2120'], ['2087', '2087', '2087', '2087', '2087', '2087', '2087', '2087', '2087', '2087', '2087'], ['2270'], ['2126', '2126', '2126', '2126', '2126', '2126', '2126', '2126'], ['2103', '2103', '2103', '2103', '2103', '2103', '2103', '2103', '2103'], ['2100', '2100', '2100', '2100', '2100'], ['2101', '2101', '2101', '2101', '2101', '2101', '2101', '2101', '2101', '2101', '2101', '2101', '2101', '2101', '2101', '2101', '2101', '2101', '2101'], ['2112', '2112', '2112', '2112'], ['2011', '2011', '2011', '2011', '2011', '2011', '2011'], ['2032', '2032', '2032'], ['2234'], ['2223', '2223'], ['2000', '2000'], ['2107', '2107', '2107', '2107', '2107', '2107', '2107', '2107', '2107', '2107', '2107', '2107', '2107', '2107', '2107', '2107', '2107', '2107', '2107', '2107', '2107', '2107', '2107', '2107'], ['2066', '2066', '2066', '2066', '2066', '2066', '2066'], ['2147', '2147', '2147', '2147', '2147', '2147', '2147', '2147', '2147', '2147'], ['2016', '2016', '2016', '2016'], ['2204', '2204', '2204', '2204'], ['2303', '2303', '2303', '2303', '2303'], ['2131', '2131'], ['2050', '2050', '2050', '2050'], ['2121', '2121', '2121', '2121', '2121', '2121', '2121', '2121', '2121', '2121', '2121', '2121', '2121'], ['2070', '2070', '2070', '2070', '2070', '2070', '2070', '2070'], ['2165'], ['2289'], ['2154', '2154', '2154', '2154', '2154', '2154', '2154', '2154', '2154', '2154', '2154', '2154', '2154', '2154', '2154', '2154', '2154', '2154', '2154', '2154', '2154', '2154'], ['2102', '2102', '2102', '2102', '2102', '2102', '2102', '2102', '2102', '2102', '2102'], ['2159', '2159', '2159', '2159'], ['2119', '2119', '2119', '2119', '2119', '2119', '2119', '2119', '2119', '2119', '2119', '2119', '2119', '2119', '2119', '2119', '2119', '2119', '2119', '2119'], ['2151'], ['2096', '2096', '2096', '2096', '2096', '2096', '2096', '2096', '2096', '2096', '2096', '2096', '2096', '2096'], ['2092', '2092'], ['2093', '2093', '2093', '2093', '2093', '2093', '2093', '2093', '2093', '2093', '2093', '2093', '2093', '2093', '2093'], ['2127', '2127', '2127', '2127', '2127'], ['2305', '2305', '2305'], ['2068'], ['2137', '2137', '2137', '2137', '2137'], ['2179'], ['2141', '2141'], ['2076', '2076', '2076', '2076', '2076', '2076', '2076', '2076', '2076', '2076', '2076', '2076', '2076', '2076', '2076', '2076'], ['418683757'], ['2079', '2079', '2079', '2079', '2079', '2079'], ['2322'], ['2913', '2913', '2913', '2913'], ['2538'], ['114'], ['2749', '2749'], ['2200'], ['2565', '2565', '2565', '2565', '2565', '2565', '2565', '2565'], ['2089', '2089', '2089'], ['2035', '2035', '2035', '2035', '2035', '2035', '2035', '2035'], ['2800', '2800'], ['2193', '2193', '2193'], ['2768', '2768'], ['2150'], ['2113', '2113', '2113', '2113'], ['2075', '2075', '2075', '2075', '2075', '2075', '2075', '2075'], ['2046', '2046', '2046', '2046', '2046'], ['2041', '2041', '2041', '2041', '2041', '2041', '2041', '2041', '2041', '2041', '2041', '2041', '2041', '2041', '2041', '2041'], ['2074', '2074', '2074', '2074', '2074', '2074', '2074', '2074', '2074'], ['2148', '2148', '2148', '2148', '2148'], ['2203', '2203', '2203', '2203', '2203'], ['2114', '2114', '2114', '2114', '2114'], ['2122', '2122', '2122', '2122', '2122', '2122', '2122', '2122', '2122', '2122'], ['2099', '2099', '2099', '2099', '2099', '2099', '2099', '2099', '2099', '2099', '2099', '2099', '2099', '2099', '2099', '2099', '2099', '2099', '2099', '2099', '2099', '2099', '2099', '2099', '2099', '2099'], ['2325', '2325', '2325', '2325'], ['2077', '2077', '2077', '2077', '2077', '2077', '2077', '2077', '2077', '2077', '2077'], ['2582'], ['2088', '2088', '2088', '2088', '2088', '2088', '2088', '2088', '2088', '2088', '2088', '2088', '2088', '2088', '2088', '2088', '2088', '2088', '2088'], ['2745', '2745', '2745', '2745'], ['2104', '2104', '2104', '2104', '2104'], ['2069', '2069', '2069', '2069', '2069'], ['2145', '2145', '2145', '2145', '2145'], ['2192', '2192', '2192'], ['2222'], ['2287', '2287', '2287'], ['2155', '2155', '2155', '2155', '2155', '2155', '2155', '2155', '2155', '2155', '2155', '2155', '2155', '2155'], ['2763', '2763', '2763', '2763', '2763', '2763', '2763'], ['2020', '2020', '2020', '2020', '2020'], ['2290', '2290', '2290', '2290'], ['2167', '2167'], ['2040', '2040', '2040'], ['2060', '2060', '2060', '2060', '2060', '2060', '2060', '2060', '2060'], ['2777'], ['2045', '2045'], ['5290', '5290'], ['2027'], ['2097', '2097', '2097', '2097', '2097'], ['2042', '2042', '2042', '2042', '2042'], ['2038', '2038', '2038', '2038'], ['2612'], ['2065', '2065', '2065', '2065', '2065', '2065', '2065', '2065', '2065', '2065', '2065', '2065', '2065', '2065', '2065', '2065'], ['2216'], ['2298', '2298', '2298', '2298', '2298'], ['2166', '2166', '2166'], ['2170', '2170', '2170'], ['2773'], ['2299', '2299'], ['2067', '2067'], ['2023', '2023', '2023', '2023', '2023', '2023'], ['2015'], ['2217', '2217', '2217', '2217'], ['2010'], ['4560', '4560'], ['2269'], ['2094', '2094', '2094', '2094', '2094'], ['2072', '2072', '2072', '2072', '2072', '2072', '2072', '2072', '2072'], ['2029', '2029', '2029'], ['2021', '2021'], ['2090', '2090', '2090', '2090', '2090'], ['2323', '2323', '2323', '2323', '2323', '2323', '2323', '2323', '2323', '2323', '2323', '2323', '2323'], ['2080', '2080', '2080'], ['2307', '2307', '2307', '2307'], ['2285', '2285', '2285', '2285', '2285'], ['2617', '2617'], ['2213', '2213', '2213', '2213'], ['2207', '2207'], ['2224'], ['2059'], ['2106', '2106', '2106', '2106', '2106', '2106', '2106', '2106', '2106', '2106', '2106'], ['2455'], ['2073', '2073', '2073', '2073', '2073', '2073', '2073', '2073'], ['2195'], ['1355'], ['2019', '2019', '2019'], ['2765', '2765', '2765', '2765', '2765', '2765', '2765', '2765', '2765'], ['2025'], ['2108', '2108'], ['2228'], ['2201'], ['2614'], ['2082', '2082', '2082', '2082', '2082', '2082', '2082', '2082', '2082'], ['2780'], ['2048', '2048', '2048'], ['2218', '2218'], ['2360', '2360', '2360', '2360'], ['2760', '2760', '2760'], ['2136', '2136', '2136'], ['94661', '94661', '94661'], ['2283', '2283', '2283', '2283', '2283', '2283', '2283', '2283', '2283', '2283'], ['2085', '2085'], ['2063', '2063', '2063', '2063'], ['2280', '2280', '2280', '2280', '2280', '2280', '2280', '2280', '2280', '2280', '2280'], ['2530', '2530'], ['2430'], ['2517'], ['3402'], ['2786', '2786'], ['2036'], ['2146', '2146'], ['2564', '2564', '2564', '2564'], ['2194'], ['2163'], ['2110'], ['2017', '2017'], ['2609'], ['2158', '2158', '2158', '2158'], ['2284', '2284'], ['2320'], ['2579'], ['2570'], ['2233', '2233'], ['2105'], ['3173'], ['2774'], ['2318'], ['2156', '2156', '2156', '2156'], ['2456', '2456', '2456', '2456'], ['2034'], ['2560'], ['2117', '2117'], ['2446', '2446'], ['2850'], ['2133', '2133'], ['2782'], ['2188'], ['2125'], ['2574', '2574'], ['2190'], ['2140', '2140'], ['2086', '2086', '2086', '2086'], ['2770', '2770', '2770'], ['2026', '2026', '2026'], ['2037', '2037', '2037'], ['2031'], ['2759', '2759', '2759'], ['2152', '2152'], ['2775'], ['76262', '76262'], ['2157'], ['2444', '2444'], ['2445'], ['2176', '2176'], ['2199', '2199', '2199'], ['2567'], ['2282', '2282', '2282', '2282', '2282'], ['2132', '2132'], ['2084', '2084'], ['2632', '2632'], ['2576'], ['2821'], ['2227', '2227', '2227'], ['2756', '2756'], ['2477'], ['2291', '2291'], ['2009', '2009'], ['4053', '4053'], ['2340'], ['2047'], ['2220', '2220', '2220'], ['2370'], ['2142'], ['3926'], ['3136', '3136']] 

私はそれがこのようにプリントアウトしたいと思います:

['2281', '2281', '2281', '2281', '2281', '2281'] 

['2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095', '2095'] 

など

+0

現在の試行を表示する必要があります。 – Sayse

+0

現在の試行が追加されました。 – CoopDaddio

+0

希望する出力例を追加できますか?あなたの説明はちょっと難しいです。 – ChickenFeet

答えて

1

私はcounter.items()を使用して、 '、'を付けずにそれを実現します。

for item,count in C.items(): 
    print([item]*count) 
+0

ありがとう、まさに私が望んでいた.. – CoopDaddio