Attribute Error:built-in function or method object has no attribute sample.
此代码生成
const dateTime = '2017-04-17 18:26:03';
const parts = dateTime.split(/[- :]/);
const wanted = `${parts[2]}/${parts[1]}/${parts[0]} ${parts[3]}:${parts[4]}`;
console.log(wanted);
我是Python初学者。请帮忙。
答案 0 :(得分:2)
您正在从random
包导入random
功能。您需要导入样本函数。
from random import sample
sample([1, 20, 3], 2)
或导入random
包并显式调用样本函数,如
import random
random.sample([1, 20, 3], 2)