2016-04-26 6 views

Antwort

1
% cat /tmp/out 
The observation of the numerous misfortunes that attend all conditions forbids 

% fold -w20 -s /tmp/out 
The observation of 
the numerous 
misfortunes that 
attend all 
conditions forbids 

Eine grobe Äquivalent fold in Python ist textwrap.fill:

import textwrap 
with open('/tmp/out', 'rb') as f: 
    content = f.read() 
    result = textwrap.fill(content, width=20) 
    print(result) 

, die von meinem Spaziergang

The observation of 
the numerous 
misfortunes that 
attend all 
conditions forbids 
+0

druckt einfach zurück. Ich werde es versuchen und zurückkommen. Vielen Dank! – donde

+0

Ihr hilfreicher Code geschätzt. Brauchen viel mehr Python! – donde

+0

Ich möchte das jetzt wirklich tun. Nicht drucken (Ergebnis). Konvertieren Sie jede 20 oder weniger Zeichenzeile in ein Element eines Arrays. Wie: Linie [1], Linie [2], Linie [3], Linie [4] Diese Elemente werden auf einer sehr kleinen OLED-Anzeige Zeile für Zeile gezeichnet. Ich kann diesen Teil machen. – donde

Verwandte Themen