You Are Here:

Community: Developer Discussion Boards

#1 Old Question Need help: coercing to Unicode - 2008-12-09, 18:56

Join Date: Dec 2008
Posts: 4
moineee
Offline
Registered User
I am new in python and in the area of "Unicode". I was trying to add 100 and 50 to get a result 150 with the following:

>>> cord1 = '100'
>>> cord2 = 50
>>> cord1 + cord2
Traceback (most recent call last):
> File "<stdin>", line 1, in ?
TypeError: coercing to Unicode: need string or buffer, int found

How do I convert '100' into integer from Unicode before I try to add cord1 and cord2? Any suggestions? Thanks...
Reply With Quote

#2 Old Re: Need help: coercing to Unicode - 2008-12-09, 19:30

Join Date: May 2004
Posts: 524
Location: Tampere, Finland
jethro.fn's Avatar
jethro.fn
Offline
Forum Nokia Champion
int() converts a string (plain or Unicode) into an integer, if it can. It raises ValueError if it cannot recognize the string.

Code:
>>> cord1 = int("100")
>>> cord2 = int(50)   # Works for integers, too.
>>> cord1 + cord2
 150
>>>
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Devenagri Unicode Font for Nokia 6600 gapata Series 40 & S60 Platform Feedback 1 2007-01-22 10:59
Problem writing Unicode data with RFile Write method rushj General Symbian C++ 3 2005-08-01 14:39
Unicode in Nokia 3510i jenda_k General Discussion 0 2004-03-08 13:24
Unicode support FAQ? vaizki General Messaging 1 2002-07-22 12:16
Unicode characters Nokia_Archive Browsing and Mark-ups 1 2002-05-17 15:09

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d81449X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZpythonQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZuserE5ftagQSxpythonX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ