简体   繁体   中英

can't multiply sequence by non-int of type 'float' ERROR when trying to multiply a float number with len(list)

I'm trying to take a random sample from a list given SPLIT_SIZE = 0.9 , but im having the following error: TypeError: can't multiply sequence by non-int of type 'float'. this is the line of code that is giving the error:

list = os.listdir(SOURCE)
training_set = random.sample(list, float(SPLIT_SIZE)*int(len(list)))

SOURCE BEING A DIRECTORY containing images.

I would appreciate any help!!

The second argument of random.sample have to be integer type.

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