View Active Threads
View Today's Posts
Home
Forums
View New Posts
View Today's Posts
My Discussions
Unanswered Posts
Unread Posts
Active Threads
Mark all forums read
Staff List
Member List
Help
Calendar
Search
Statistics
Interpreter
IRC
convert a string into an int in Python
Python Forum
Python Coding
General Coding Help
Thread Rating:
0 Vote(s) - 0 Average
1
2
3
4
5
Thread Modes
convert a string into an int in Python
anjita
Banned
Posts:
3
Threads:
2
Joined:
Jan 2019
#1
Jan-17-2019, 10:35 AM
How would I convert a string into an int in Python?
Reply
Find
Reply
Larz60+
aetate et sapientia
Posts:
12,034
Threads:
486
Joined:
Sep 2016
Reputation:
452
#2
Jan-17-2019, 10:58 AM
# this is string mystring = '12345' # convert to int myint = int(mystring)
Reply
Find
Reply
sandeepatel
Banned
Posts:
2
Threads:
1
Joined:
Jan 2019
#3
Jan-18-2019, 10:37 AM
(This post was last modified: Jan-18-2019, 08:34 PM by
buran
.)
If a string contains only numerical characters, you can convert it into an integer using the int() function.
>>> int('227')
227
Let’s check the types:
>>> type('227')
<class ‘str’>
>>> type(int('227'))
<class ‘int’>
Reply
Find
Reply
Possibly Related Threads…
Thread
Author
Replies
Views
Last Post
convert string to float in list
jacklee26
6
3,517
Feb-13-2023, 01:14 AM
Last Post
:
jacklee26
how to convert tuple value into string
mg24
2
4,106
Oct-06-2022, 08:13 AM
Last Post
:
DeaD_EyE
Convert string to float problem
vasik006
8
5,484
Jun-03-2022, 06:41 PM
Last Post
:
deanhystad
Convert a string to a function
mikepy
8
4,714
May-13-2022, 07:28 PM
Last Post
:
mikepy
How to convert string to variable?
chatguy
5
4,965
Apr-12-2022, 08:31 PM
Last Post
:
buran
Convert string to int
Frankduc
8
3,976
Feb-13-2022, 04:50 PM
Last Post
:
menator01
Convert string to path using Python 2.7
tester_V
10
9,508
Nov-20-2021, 02:20 PM
Last Post
:
snippsat
Convert each element of a list to a string for processing
tester_V
6
7,696
Jun-16-2021, 02:11 AM
Last Post
:
tester_V
convert unlabeled list of tuples to json (string)
masterAndreas
4
9,282
Apr-27-2021, 10:35 AM
Last Post
:
masterAndreas
Convert String of an int array to a Numpy array of ints
mdsousa
5
7,615
Apr-08-2021, 08:00 PM
Last Post
:
mdsousa
Users browsing this thread: 1 Guest(s)
View a Printable Version
Forum Jump:
Private Messages
User Control Panel
Who's Online
Search
Forum Home
Python Coding
-- General Coding Help
-- Data Science
-- Homework
-- GUI
-- Game Development
-- Networking
-- Web Scraping & Web Development
General
-- News and Discussions
-- Tutorials
---- Tutorial Requests and Submissions
---- Python Installation and Execution
---- Fundamentals
---- Common pitfalls and what to do
---- Web Scraping
---- Web Tutorials
---- GUI tutorials
---- Game Tutorials
---- Networking Tutorials
-- Code sharing
-- Code Review
-- Jobs
Forum & Off Topic
-- Board
---- Weekly Top Picks
-- Bar
User Panel
Messages
Log Out
My Profile
Pay your profile a visit
User Control Panel
Do some changes on your profile
My Messages
View private messages
unread
Avatar
Change avatar
Signature
Change signature
Announcements
Announcement #1
8/1/2020
Announcement #2
8/2/2020
Announcement #3
8/6/2020
Login to Python Forum
Enter your details to login to your account:
Remember me
Lost Password?
Login
Don't have an account yet?
Sign Up!
Linear Mode
Threaded Mode