
14.02.2022, 01:59
|
|
Познающий
Регистрация: 21.03.2020
Сообщений: 78
С нами:
3235556
Репутация:
13
|
|
Python:
Код:
import
random
def
getRandomLineFromFile
(
filepath
)
:
with
open
(
filepath
)
as
f
:
lines
=
f
.
readlines
(
)
return
lines
[
random
.
randint
(
0
,
len
(
lines
)
-
1
)
]
filepath
=
"default.txt"
print
(
getRandomLineFromFile
(
filepath
)
)
|
|
|