current position:Home>module random has no attribute choices

module random has no attribute choices

2022-02-03 01:59:38 CSDN Q & A

It's weird
stay pycharm The code written on
use random.choices( ) Just report a mistake
Switch to random.sample( ) Can run
I have no idea what the problem is
yes python Is the version too old




Refer to the answer 1:



Refer to the answer 2:



Refer to the answer 3:

random.choices() The method is 3.6 Features added in version ., Look at you python Is the version lower than 3.6

img




Refer to the answer 4:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202030159363703.html

Random recommended