简体   繁体   中英

how to take particular the value from the list

s = [(Decimal('1655275144000'),)]

I need to take only the '1655275144000' in a variable

I have the below error when I call s[0] , how do I get around it?

在此处输入图像描述

Import class Decimal:

from decimal import Decimal

And then, your value is inside a tuple, inside and array, so in order to access it:

s[0][0]

This error show you forgot to import the Decimal module. Just add this to the top of your file:

from decimal import Decimal

I think you need to import Decimal before getting decimals in that list. This will solve your problem.

You are missing the import for the Decimal you are using. Do this:

import decimal
from decimal import Decimal

s = [(Decimal('1655275144000'),)]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM