User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 392,063 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,251 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser:
Views: 1534 | Replies: 4
Reply
Join Date: Jul 2005
Posts: 9
Reputation: peaceofmind is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
peaceofmind's Avatar
peaceofmind peaceofmind is offline Offline
Newbie Poster

problem with string

  #1  
Jul 21st, 2005
hi
I need some help for this script
I have
--------------------
cursor = conn.cursor()
cursor.execute("select * from playlist limit 5")
result = cursor.fetchall()
# iterate through resultset
playlist_txt = ''
for record in result:
 mp3id = record[0]
 mp3_title = record[1]
 mp3_artist = record[2]
 playlist_txt += mp3id + mp3_title + mp3_artist
 #print mp3id , " - ", mp3_title , ' - ', mp3_artist , "<br />"
cursor.close()
conn.close()
------------------
#and want to print this out of "for record in result:"
print playlist_txt

#but there is an error in
playlist_txt += mp3id + mp3_title + mp3_artist

10x in advance ))
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2005
Location: Troy
Posts: 1,277
Reputation: Rashakil Fol has a spectacular aura about Rashakil Fol has a spectacular aura about 
Rep Power: 7
Solved Threads: 36
Colleague
Rashakil Fol's Avatar
Rashakil Fol Rashakil Fol is offline Offline
Salamander Man

Re: problem with string

  #2  
Jul 21st, 2005
With Python questions, you definitely need to use CODE tags.
Reply With Quote  
Join Date: Jul 2005
Posts: 9
Reputation: peaceofmind is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
peaceofmind's Avatar
peaceofmind peaceofmind is offline Offline
Newbie Poster

Re: problem with string

  #3  
Jul 21st, 2005
sorry but I write here for the first time
Now I know 10x
Reply With Quote  
Join Date: Oct 2004
Location: Mojave Desert
Posts: 2,394
Reputation: vegaseat will become famous soon enough vegaseat will become famous soon enough 
Rep Power: 9
Solved Threads: 172
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
Kickbutt Moderator

Solution Re: problem with string

  #4  
Jul 22nd, 2005
Can you give us the error message and a little more of your code?

Without that info, I don't know what your resultset looks like. I can only assume that mp3id could be an integer and needs to be converted to a string to work with the + concatination. In this case mp3id = str(record[0]) would do the trick.
May 'the Google' be with you!
Reply With Quote  
Join Date: Jul 2005
Posts: 9
Reputation: peaceofmind is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
peaceofmind's Avatar
peaceofmind peaceofmind is offline Offline
Newbie Poster

Re: problem with string

  #5  
Jul 22nd, 2005
10x for the help
I try with this and it work perfect )
 
 playlist_txt += str(mp3id) +  str(mp3_title) + str(mp3_artist) + '<br>'
 #playlist_txt += "%s %s %s <br>" % (mp3id, mp3_title, mp3_artist)

Edit: added / to ending [/code]
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Python Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Python Forum

All times are GMT -4. The time now is 11:49 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC