File "C:\PyCharm\datasetScripts\main.py", line 11 print(f"file {os.path.join(folderpath,…
Jump to turn (6)
- 1File "C:\PyCharm\datasetScripts\main.py", line 11 print(f"file {os.path.join(fol
- 2как проверить, что папка существует?
- 3как мне превратить путь в путь для операционной системы
- 4Traceback (most recent call last): File "C:\PyCharm\datasetScripts\main.py", lin
- 5for i in range(0, len(filesinfolder)): #Создаём новое имя файла newfilename = f'
- 6Почему то после следующего кода в папке остается только один - последний - файл
- User
File "C:\PyCharm\datasetScripts\main.py", line 11 print(f"file {os.path.join(folder_path, file)} replaced to {os.path.join(os.path.join(folder_path,"sub"), file)}") ^ SyntaxError: f-string: unmatched '('
- Assistant
This error is due to the unmatched parentheses in the f-string. To fix this issue, you need to correct the f-string syntax. Here is the corrected line of code:
pythonprint(f"file {os.path.join(folder_path, file)} replaced to {os.path.join(os.path.join(folder_path,'sub'), file)}")By replacing the inner
()with'sub'inos.path.join(), the f-string will be properly formatted and the SyntaxError will be resolved. - User