Answers for "convert decimal string to int python"

1

Python string to int

x = "594152"
y = int(x)
Posted by: Guest on October-22-2021
1

decimal to int python

print "%.4f" % 3.3333333333
3.3333
print "%.4f" % 6.6666666666
6.6667
Posted by: Guest on April-06-2020
-1

python string to decimal

import decimal
list = ["3","4.5","6"]
string = "6"
list2 = []
control = Decimal(7)
for i in list:
    list2.append(Decimal(i))
decimal_string = Decimal(string)
#Control is to show that a decimal number has a class of <class 'decimal.Decimal'>
print(type(control))
#<class 'decimal.Decimal'>
print(type(decimal_string))
for i in list2:
    print(i)
    print(type(i))
    #<class 'decimal.Decimal'>
#As shown above, converting strings and arrays to a decimal is quite easy.
#I hope this helps you to solve your problem :)
Posted by: Guest on August-16-2021

Code answers related to "convert decimal string to int python"

Python Answers by Framework

Browse Popular Code Answers by Language