31 lines
765 B
Python
31 lines
765 B
Python
import os
|
||
|
||
|
||
def list_levels():
|
||
files = os.listdir(path=".")
|
||
result = []
|
||
for file in files:
|
||
if file.lower().endswith('.txt'):
|
||
result.append(file)
|
||
|
||
return result
|
||
|
||
|
||
def load(file):
|
||
# 1 загрузить весь файл в строку
|
||
f = open(file, "r")
|
||
s = f.read()
|
||
|
||
# 2 заменить все пробелы и переводы строки на ничего
|
||
s = s.replace(" ", "")
|
||
s = s.replace('\n', "")
|
||
|
||
# 3 из полученной строки создать массив используя разделитель ","
|
||
a = s.split(",")
|
||
|
||
# а - массив строк, в которых хранятся числа
|
||
b = []
|
||
|
||
f.close()
|
||
return a
|