Найти - Пользователи
Полная версия: random.sample
Начало » Python для новичков » random.sample
1
webstghost
Код из примеров “random”

# coding: utf-8
import random
random.sample([1, 2, 3, 4, 5],  3)

Говорит AttributeError: ‘module’ object has no attribute ‘sample’
reclosedev
Вижу два варианта:
- Python версии < 2.3
- в папке есть файл random.py или random.pyc или random.pyo

Что выведет код?
print(random.__file__)
webstghost
Да, там был файл random.py. Спасиб.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB