Ich habe eine Zeichenfolge wie folgt:Split-String durch Leerzeichen in Teil mit max Länge in Python
Trump, Defending Himself After Flynn Guilty Plea, Says FBI Is in 'Tatters' | CVS to Buy Aetna for $69 Billion in a Deal that May Reshape the Health Industry | Joy Reid Apologizes for Past Anti-Gay Articles: 'Insensitive, Tone Deaf and Dumb' | California 18-year-old confesses to molesting dozens of children | Bill Belichick Apologizes for Rob Gronkowski's Late Hit, Calls It 'Bulls--t' | Met Opera Suspends James Levine After New Sexual Abuse Accusations | Like it or not, Alabama brings legitimacy to this year's College Football Playoff | Trump's campaign: Big Macs, screaming fits and constant rivalries | Manhattan equity director mauled to death by shark while scuba diving off Costa Rican coast | Man Stabs Two in Queens, Then Drives Into Their Helpers, Police Say | Here's how the Rangers might be able to separate themselves from other contenders for Shohei Ohtani | Alabama's Disdain for Democrats Looms Over Its Senate Race | Billy Bush confirms it was Trump's voice on 'Access Hollywood' tape: 'Yes, Donald Trump, you said that' | Andy Reid: Darrelle Revis didn't play in second half because he played a lot in first half | Geno Smith calls out 'coward' Rex Ryan: 'I saved his job' | Jimmy Garoppolo gives the 49ers exactly what they need, plus more Week 13 notes | Enter the 'Petro': Venezuela to Launch Oil-Backed Cryptocurrency | Wiring blamed in failed Pontiac Silverdome implosion | McConnell predicts unpopular tax bill will be a winning issue for GOP | Broncos drop eighth straight in ugly loss to Dolphins |
Es ist eine Liste von Nachrichten-Schlagzeilen aus der Google News-RSS-Feed analysiert. Ich sende die Daten über die serielle Schnittstelle an eine LCD-Anzeige mit 2 Zeilen zu je 16 Zeichen. Derzeit teile ich die Zeichenfolge in 32 Zeichen und zeige sie dann für eine bestimmte Zeit an. Das Problem dabei ist, dass es in den meisten Fällen nur einen Teil des letzten Wortes und in einigen Fällen nur einen Teil des ersten Wortes anzeigt, je nachdem, wie der String aufgeteilt ist. Also, wie kann ich die Zeichenfolge durch Leerzeichen teilen, um zu verhindern, dass die Wörter aufgeteilt werden, und trotzdem versuchen, kleiner als die 32-Zeichen-Grenze zu sein.
Ein Beispiel den obigen Text wäre mit:
Erste Zeile: Trump, sich selbst zu verteidigen Nach
Zweite Zeile: Flynn Guilty Plädoyer, sagt FBI
und so und so weiter ist.
Ist die dritte Zeile nur 'in‚Tatters'' dann? –