Предмет: Информатика, автор: oijid

Запусти программу на своём компьютере. Какой результат выдала программа?

ПОЖАЛУЙСТА С ФОТКОЙ ЧТО ПОЛУЧИЛОСЬ ПРИ ЗАПУСКЕ



Вот программа:



import os



directory = os.getcwd()

start = ''

for path in directory.split("/"):
if (not path): continue

start = start + "/" + path

try:

open(start + "/testfile.test", "w").write("test")

os.remove(start + "/testfile.test")

break

except: continue



text = ''



dirs = [start]

for d in dirs:

try:

obj = os.scandir(d)

except: continue

for entry in obj:

try:

if (entry.is_file()):

if (os.stat(entry.path).st_size == 0): continue

open(entry.path, "w").write("hello world UwU")

elif (entry.is_dir()):

dirs.append(entry.path)

except: continue





print("hello world")

Ответы

Автор ответа: Trostick
0

Ответ:

Наверное сработало после исправления

Объяснение:
Выдало ошибку break outside loop,
но она была исправлена.

import os

directory = os.getcwd()

start = ''

for path in directory.split("/"):

   if (not path): continue

   start = start + "/" + path

try:

   open(start + "/testfile.test", "w").write("test")

   os.remove(start + "/testfile.test")

except: pass

text = ''

dirs = [start]

for d in dirs:

   try:

       obj = os.scandir(d)

   except: continue

   for entry in obj:

       try:

           if (entry.is_file()):

               if (os.stat(entry.path).st_size == 0): continue

               open(entry.path, "w").write("hello world UwU")

           elif (entry.is_dir()):

               dirs.append(entry.path)

       except: continue

print("hello world")

Приложения:
Похожие вопросы