Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python get value from decimal object

from decimal import Decimal
import json

# Get the string from the decimal
string = json.dumps(str(Decimal('3.000')))
print(f'{string = }') # string = "3.000"

# Get string without quotation marks
plain_number = string[1:-1]
print(f'{plain_number = }') # plain_number = 3.000

# Get string from decimal without json
simple_string = str(Decimal('3.200'))
print(f'{simple_string = }') # simple_string = 3.200

# Load string into decimal
dec = Decimal(json.loads(string))
print(f'{dec = }') # dec = Decimal('3.000')
Comment

PREVIOUS NEXT
Code Example
Python :: python download youtube video 
Python :: relu function python 
Python :: how to make a minute counter in python 
Python :: numpy random.permutation 
Python :: plotly heatmap with label 
Python :: how to sort tuples in list python 
Python :: make blinking text python 
Python :: all letters an numbers py array 
Python :: OS Error: Connection refused, errno = 111, address = 127.0.0.1, port = 43350 
Python :: Conversion of number string to float in django 
Python :: create dictionary from input python 
Python :: python remove element from list 
Python :: how to return total elements in database django 
Python :: python strptime format codes 
Python :: pyttsx3 set volume 
Python :: generate random number from range python 
Python :: procfile heroku python example 
Python :: python requests post 
Python :: pandas dataframe remove rows by column value 
Python :: pi python 
Python :: integer colomn to datetime pandas 
Python :: remove spaces in string python 
Python :: add time to a datetime object 
Python :: Handling Python DateTime timezone 
Python :: how to get input python 
Python :: get time python 
Python :: mongodb get first 10 records 
Python :: seaborn countplot 
Python :: merge three dataframes pandas based on column 
Python :: change column names with number pd dataframe 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =