Solved

Convering long to string variable

Posted on 2006-11-22
2
425 Views
Last Modified: 2010-04-16
Hi,
How do i typecast/convert a long varialble ( for example 123456L) to a string variable (for example '123456')?

Thanks
0
Comment
Question by:jyotishb
2 Comments
 
LVL 14

Accepted Solution

by:
RichieHindle earned 500 total points
Comment Utility
Use the str function:

>>> str(123456L)
'123456'

or the "%d" string format:

>>> print "The number is %d." % 123456L
The number is 123456.
0
 
LVL 17

Expert Comment

by:ramrom
Comment Utility
These answers are not exhaustive but they are more than adequate.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Plenty of writing has gone on the web trying to compare Python with other competitive programming languages and vice versa. However, not much has been put into a wholistic perspective. This article should help you decide whether to adopt Python as a…
The really strange introduction Once upon a time there were individuals who intentionally put the grass seeds to the soil with anticipation of solving their nutrition problems. Or they maybe only played with seeds and noticed what happened... Som…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
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 …

728 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

11 Experts available now in Live!

Get 1:1 Help Now