Convert String to Long in Python Last Updated : 28 Jul, 2020 Comments Improve Suggest changes Like Article Like Report Python defines type conversion functions to directly convert one data type to another. This article is aimed at providing information about converting a string to long. Converting String to long A long is an integer type value that has unlimited length. By converting a string into long we are translating the value of string type to long type. In Python3 int is upgraded to long by default which means that all the integers are long in Python3. So we can use int() to convert a string to long in Python. Syntax : int(string, base) Parameter : string : consists of 1's and 0's base : (integer value) base of the number.example 1 Example 1: Python3 a_string = "123" print(type(a_string)) # Converting to long a_long = int(a_string) print(a_long) print(type(a_long)) Output: <class 'str'> 123 <class 'int'> Example 2: Python3 a='0x' arr0 = '00000018000004000000000000000000' arr1 = '00000000000000000000000000000000' arr2 = 'fe000000000000000000000000000000' arr3 = '00000000000000000000000000ffffff' data = a+arr0+arr1+arr2+arr3 print(data) print(type(data)) # Converting to long data1 = int(data, 16) print(type(data1)) Output: 0x0000001800000400000000000000000000000000000000000000000000000000fe00000000000000000000000000000000000000000000000000000000ffffff <type 'str'> <type 'int'> Comment More infoAdvertise with us Next Article Convert String to Long in Python D deepanshumehra1410 Follow Improve Article Tags : Python Python-Built-in-functions python-basics Practice Tags : python Similar Reads Convert String to Int in Python In Python, converting a string to an integer is important for performing mathematical operations, processing user input and efficiently handling data. This article will explore different ways to perform this conversion, including error handling and other method to validate input string during conver 3 min read Convert integer to string in Python In this article, weâll explore different methods for converting an integer to a string in Python. The most straightforward approach is using the str() function.Using str() Functionstr() function is the simplest and most commonly used method to convert an integer to a string.Pythonn = 42 s = str(n) p 2 min read Convert Hex to String in Python Hexadecimal (base-16) is a compact way of representing binary data using digits 0-9 and letters A-F. It's commonly used in encoding, networking, cryptography and low-level programming. In Python, converting hex to string is straightforward and useful for processing encoded data.Using List Comprehens 2 min read Convert String to Float in Python The goal of converting a string to a float in Python is to ensure that numeric text, such as "33.28", can be used in mathematical operations. For example, if a variable contains the value "33.28", we may want to convert it to a float to perform operations like addition or division. Let's explore dif 2 min read Convert Hex String To Integer in Python Hexadecimal representation is commonly used in computer science and programming, especially when dealing with low-level operations or data encoding. In Python, converting a hex string to an integer is a frequent operation, and developers have multiple approaches at their disposal to achieve this tas 2 min read Like