import sys import os class Notepad() x = str() y = str() def save(self): print('''Введите путь файла для копирования - c:\\''afs''\\''asdffads''\\''корректный путь''') text1 = sys.stdin.readline() if text1 == ('Здесь должен быть указан корректный путь, если он корректный то открывает этот путь, например \\с:\\user\\итд, как сделать'): for text1 in range(''): #здесь ошибка, не знаю как сделать x = open(text1, 'r') filetext1 = x.read() else: print('Выводит сообщение что неправильно ввели путь и возвращает на строку 7-8, как сделать') print('''Введите путь файла для создания, в который хотите скопировать - c:\\''afs''\\''asdffads''\\''корректный путь''') text2 = sys.stdin.readline() if text2 == ('Здесь должен быть указан корректный путь, если он корректный то открывает этот путь, например \\с:\\user\\итд, как сделать'): for text2 in range (''): #здесь ошибка, не знаю как сделать y = open(text2, 'w') text2 = y.write(filetext1) x.close() y.close() y = open(text2, 'r') filetext2 = y.read() print(filetext2) #выводит содержимое второго файла с информацией откопированной из первого else: print('Выводит сообщение что неправильно ввели путь и возвращает на строку 7-8, как сделать') Hello, I am learning to program. Tell me, please, I want to make a program that takes the value of the path of the first file, processes it, then takes the value of the path of the second file, which you need to create and copy into it the values from the first. Text files. How to make the program understand the correct path to the file? How to make a return from a certain point of code to the desired one used earlier? I would like to leave the prog in this form, as I still do not understand other types. Modules can add others. Please correct the errors, thank you.
UPDATE:
import os class Notepad: def open(): while True: firstfile = input('Введите путь файла для копирования ') if os.path.exists(firstfile): print('Копируем file'.format(firstfile)) text1 = open(firstfile, 'r') filetext1 = text1.read() text1.close() break else: print('Неудалось найти файл'.format(firstfile)) def create(): while True: secondfile = input('Создайте файл с необходимым путем') if os.path.exists(secondfile): print('Создаем новый файл'.format(secondfile)) text2 = open(secondfile, 'w') filetext2 = text2.write(filetext1) filetext2.close() break else: print('Неудалось создать файл'.format(secondfile)) def opennew(): while True: if os.path.exists(secondfile): text2 = open(secondfile, 'r') filetext2 = y.read() print(filetext2) break This code is made, designed in the form of classes and functions. I run into the python - all the rules. Then I call the open () function and get an error. Why is that? What to fix? What to read about?
>>> open() Traceback (most recent call last): File "<pyshell#1>", line 1, in <module> open() TypeError: Required argument 'file' (pos 1) not found