Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Convering long to string variable

Posted on 2006-11-22
2
Medium Priority
?
435 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 1000 total points
ID: 17998193
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
ID: 17999262
These answers are not exhaustive but they are more than adequate.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Flask is a microframework for Python based on Werkzeug and Jinja 2. This requires you to have a good understanding of Python 2.7. Lets install Flask! To install Flask you can use a python repository for libraries tool called pip. Download this f…
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 modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…

824 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