How to Split Strings in Python

Save

Python is a programming language that allows you to write programs for Web applications. By using Python functions you create scripts to execute on Web servers. The Python tools for selecting and editing the character strings from Web databases gives users the ability to present application data in a variety formats. You need to split a string in Python program into a list of separate elements, if you search for a particular sequence of characters in the database data.

  • Click "Start" in Windows and then click "Python IDE."

  • Click "File" and then click "New."

  • Enter the following code in the open window to split first record

    in the "testdb" database into 2 character strings:

    li = 'server=testdb', 'uid=sa', 'database=master', 'pwd=root'

    s = ";".split(li)

    s.split(";", 1) 2

  • Click "File' and then click "Save." Enter "split2.py" into the open window and then click "OK" to add Python script to the database server.

References

  • Photo Credit Ablestock.com/AbleStock.com/Getty Images
Promoted By Zergnet

Comments

You May Also Like

  • How to Add a New Line in Visual Basic

    A new line character (often abbreviated as CRLF for Carriage Return Line Feed) instructs a software form to word-wrap the characters in...

  • How to Split a String in C

    ANSI C is one of the oldest and most widely used lower level programming languages still in use by modern, professional programmers....

Related Searches

Check It Out

Geek Vs Geek: Robot battles, hoverboard drag race, and more

M
Is DIY in your DNA? Become part of our maker community.
Submit Your Work!