python splitting a string

Posted on 2006-05-27
Last Modified: 2010-04-16
I am trying to split a string.  Consider the following:

>>> import pgdb
>>> db=pgdb.connect(user="reports",password="",database="fsn")
>>> cursor=db.cursor()
>>> cursor.execute("""select referencenames from gnr where lastname='Allison'""",())
>>> row=cursor.fetchone()
>>> print row
['Marshall Partington, friend \r\nAllyce Povick friend ']
>>> list=row[0].split(r"\n")
>>> print list
['Marshall Partington, friend \r\nAllyce Povick friend ']

I think the last line should be a two element list split on \n.  What am I doing wrong?
Question by:astar666
    1 Comment
    LVL 17

    Accepted Solution


    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    Variable is a place holder or reserved memory locations to store any value. Which means whenever we create a variable, indirectly we are reserving some space in the memory. The interpreter assigns or allocates some space in the memory based on the d…
    Dictionaries contain key:value pairs. Which means a collection of tuples with an attribute name and an assigned value to it. The semicolon present in between each key and values and attribute with values are delimited with a comma.  In python we can…
    Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
    Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now