Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old April 3rd, 2003, 05:02 PM
marron79's Avatar
marron79 marron79 is offline
Rut row Raggy!
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2001
Location: Tornado Alley
Posts: 558 marron79 User rank is Private First Class (20 - 50 Reputation Level)marron79 User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 9 h 41 sec
Reputation Power: 8
Question How do you combine strings and ints?

How do you combine a string and an int in Python? For example, I was messing around with some of the winsound functions, and when I tried something like:

print "Bitrate: " + params[1]

Params[1] being the second element in the params array, which is contains information about the sound file (ie. type, bitrate, mono/stereo, etc.). I got an error saying I couldn't combine a string with an int (which, by the way is the stupidest syntax rule I've ever heard).
__________________
Matt

Reply With Quote
  #2  
Old April 3rd, 2003, 06:11 PM
Strike Strike is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2001
Location: Houston, TX
Posts: 383 Strike User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 41 m 27 sec
Reputation Power: 7
Send a message via ICQ to Strike Send a message via AIM to Strike Send a message via Yahoo to Strike
Re: How do you combine strings and ints?

Quote:
Originally posted by marron79
How do you combine a string and an int in Python? For example, I was messing around with some of the winsound functions, and when I tried something like:

print "Bitrate: " + params[1]

Params[1] being the second element in the params array, which is contains information about the sound file (ie. type, bitrate, mono/stereo, etc.). I got an error saying I couldn't combine a string with an int (which, by the way is the stupidest syntax rule I've ever heard).


Code:
print "Bitrate: %d" % params[1]
print "Bitrate: " + str(params[1])


Either will work.

Have you gone through the tutorial on www.python.org ?
__________________
Debian - because life's too short for worrying.
Best. (Python.) IRC bot. ever.

Reply With Quote
  #3  
Old April 3rd, 2003, 07:31 PM
marron79's Avatar
marron79 marron79 is offline
Rut row Raggy!
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2001
Location: Tornado Alley
Posts: 558 marron79 User rank is Private First Class (20 - 50 Reputation Level)marron79 User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 9 h 41 sec
Reputation Power: 8
Quote:
print "Bitrate: " + str(params[1])


Converting the int to a string....duh! Why didn't I think of that?

Thanks!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > How do you combine strings and ints?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway