| | |
Splitting a message up into two
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2008
Posts: 58
Reputation:
Solved Threads: 0
I am trying to spilt a message in two, if the number of characters is greater that 600, so that each message has no more than 600 characters.
How can i do this
i know how to get the message length
but i am not sure od how to split it.
How can i do this
i know how to get the message length
Python Syntax (Toggle Plain Text)
Message = "sdkfhdslkfhdskfhsdlfjsdlk" print len(Message)
but i am not sure od how to split it.
python Syntax (Toggle Plain Text)
pieces = [] while len(message) > 600: pieces.append(message[:600]) # slice from the start up to (but not including) the 600th character. message= message[600:] #slice from the 600th character to the end. pieces.append(message)
That should split the string up into pieces that are 600 characters long or less. The pieces are stored in the list 'pieces'.
Last edited by scru; Feb 25th, 2009 at 1:18 pm.
![]() |
Similar Threads
- Getting Error Message, during compile process (C++)
- HELP linking header files... undefined error message in g++ (C++)
- Returns null pointer (C++)
- The Definitive Guide to which Forum Software Information (Social Media and Online Communities)
- Data consolidation across an array a.k.a. Hashed to death... heeelp... (Perl)
- How would I make a tile map, that is easily alterable? (Python)
- Zend PHP Certification (PHP)
- Need help with DirectX code (C)
Other Threads in the Python Forum
- Previous Thread: pygtk: Disable buttons, Comboboxes, checkboxes...
- Next Thread: Printing In Python
| Thread Tools | Search this Thread |
accessdenied advanced application argv beginner change code command convert csv cursor def dictionary digital dynamic dynamically edit editing enter event examples excel file float format frange function google gui homework i/o import input jaunty java keyboard lapse line linux list lists loop microphone mouse movingimageswithpygame newb number numbers obexftp output parameters parsing path port prime programming projects py2exe pygame pygtk pyopengl python random recursion remote return reverse scrolledtext session simple skinning smtp sprite stderr string strings strip subprocess syntax table tennis terminal text thread threading time tkinter tlapse tuple tutorial ubuntu unicode unit urllib urllib2 variable voip web-scrape windows wxpython






