Python: проверьте, существует ли файл

| | | | | | | |

–ú–µ—Ç–æ–¥ Python os.path.isdir () –ø—Ä–æ–≤–µ—Ä—è–µ—Ç, —Å—É—â–µ—Å—Ç–≤—É–µ—Ç –ª–∏ –∫–∞—Ç–∞–ª–æ–≥. os.path.isfile () –ø—Ä–æ–≤–µ—Ä—è–µ—Ç, —Å—É—â–µ—Å—Ç–≤—É–µ—Ç –ª–∏ —Ñ–∞–π–ª. –û–±–∞ —ç—Ç–∏ –º–µ—Ç–æ–¥–∞ —è–≤–ª—è—é—Ç—Å—è —á–∞—Å—Ç—å—é –±–∏–±–ª–∏–æ—Ç–µ–∫–∏ –û–° Python.

–ü—Ä–æ–≤–µ—Ä–∫–∞ —Å—É—â–µ—Å—Ç–≤–æ–≤–∞–Ω–∏—è –æ–ø—Ä–µ–¥–µ–ª–µ–Ω–Ω–æ–≥–æ —Ñ–∞–π–ª–∞ –∏–ª–∏ –∫–∞—Ç–∞–ª–æ–≥–∞ –∏–º–µ–µ—Ç —Ä—è–¥ –ø—Ä–∏–º–µ–Ω–µ–Ω–∏–π –≤ Python. –ú–æ–¥—É–ª—å os –≤–∫–ª—é—á–∞–µ—Ç —Ç—Ä–∏ –º–µ—Ç–æ–¥–∞, –∫–æ—Ç–æ—Ä—ã–µ –º–æ–∂–Ω–æ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å –¥–ª—è –ø—Ä–æ–≤–µ—Ä–∫–∏ —Å—É—â–µ—Å—Ç–≤–æ–≤–∞–Ω–∏—è –æ–ø—Ä–µ–¥–µ–ª–µ–Ω–Ω–æ–≥–æ —Ñ–∞–π–ª–∞ –∏–ª–∏ –∫–∞—Ç–∞–ª–æ–≥–∞: isfile (), isdir () –∏ exists ().

–í —ç—Ç–æ–º —Ä—É–∫–æ–≤–æ–¥—Å—Ç–≤–µ –º—ã –æ–±—Å—É–¥–∏–º, –∫–∞–∫ –≤—ã –º–æ–∂–µ—Ç–µ –ø—Ä–æ–≤–µ—Ä–∏—Ç—å, —Å—É—â–µ—Å—Ç–≤—É–µ—Ç –ª–∏ –æ–ø—Ä–µ–¥–µ–ª–µ–Ω–Ω—ã–π —Ñ–∞–π–ª –∏–ª–∏ –∫–∞—Ç–∞–ª–æ–≥, –∏—Å–ø–æ–ª—å–∑—É—è isfile (), isdir () –∏ exists () –≤ Python. –ú—ã —Ä–∞—Å—Å–º–æ—Ç—Ä–∏–º –Ω–µ—Å–∫–æ–ª—å–∫–æ –ø—Ä–∏–º–µ—Ä–æ–≤ –∫–∞–∂–¥–æ–≥–æ –∏–∑ —ç—Ç–∏—Ö –º–µ—Ç–æ–¥–æ–≤ –≤ –¥–µ–π—Å—Ç–≤–∏–∏, —á—Ç–æ–±—ã –ø—Ä–æ–∏–ª–ª—é—Å—Ç—Ä–∏—Ä–æ–≤–∞—Ç—å, –∫–∞–∫ –æ–Ω–∏ —Ä–∞–±–æ—Ç–∞—é—Ç.

OS Refresher

–í—Å—Ç—Ä–æ–µ–Ω–Ω—ã–π –≤ Python –º–æ–¥—É–ª—å os –ø–æ–∑–≤–æ–ª—è–µ—Ç –ø–æ–ª—É—á–∏—Ç—å –¥–æ—Å—Ç—É–ø –∫ —Ñ—É–Ω–∫—Ü–∏—è–º –æ–ø–µ—Ä–∞—Ü–∏–æ–Ω–Ω–æ–π —Å–∏—Å—Ç–µ–º—ã –≤ –≤–∞—à–µ–º –∫–æ–¥–µ.

Os - —ç—Ç–æ –º–æ–¥—É–ª—å Python, –∞ —ç—Ç–æ –æ–∑–Ω–∞—á–∞–µ—Ç, —á—Ç–æ –ø–µ—Ä–µ–¥ –µ–≥–æ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞–Ω–∏–µ–º –Ω–∞–º –Ω–µ–æ–±—Ö–æ–¥–∏–º–æ –∏–º–ø–æ—Ä—Ç–∏—Ä–æ–≤–∞—Ç—å –º–æ–¥—É–ª—å –≤ –Ω–∞—à –∫–æ–¥. –ú—ã –±—É–¥–µ–º –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å —Ñ—É–Ω–∫—Ü–∏–∏ —Ç–æ—á–∫–∏ –ø—É—Ç–∏ –º–æ–¥—É–ª—è —Ç–æ–ª—å–∫–æ –¥–ª—è –ø—Ä–æ–≤–µ—Ä–∫–∏ —Å—É—â–µ—Å—Ç–≤–æ–≤–∞–Ω–∏—è –æ–ø—Ä–µ–¥–µ–ª–µ–Ω–Ω—ã—Ö —Ñ–∞–π–ª–æ–≤ –∏–ª–∏ –∫–∞—Ç–∞–ª–æ–≥–æ–≤. –ò—Ç–∞–∫, –Ω–∞–º –Ω—É–∂–Ω–æ —Ç–æ–ª—å–∫–æ –∏–º–ø–æ—Ä—Ç–∏—Ä–æ–≤–∞—Ç—å –º–æ–¥—É–ª—å os.path.

–ú—ã –º–æ–∂–µ–º —Å–¥–µ–ª–∞—Ç—å —ç—Ç–æ —Å –ø–æ–º–æ—â—å—é –∏–Ω—Å—Ç—Ä—É–∫—Ü–∏–∏ –∏–º–ø–æ—Ä—Ç–∞ Python :

Python –ü—Ä–æ–≤–µ—Ä–∏—Ç—å, –µ—Å–ª–∏ —Ñ–∞–π–ª –°—É—â–µ—Å—Ç–≤—É–µ—Ç

–ú–µ—Ç–æ–¥ os.path.isfile () –ø—Ä–æ–≤–µ—Ä—è–µ—Ç, —Å—É—â–µ—Å—Ç–≤—É–µ—Ç –ª–∏ —Ñ–∞–π–ª –≤ Python. os.path.isfile () –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç True –∏–ª–∏ False, –≤ –∑–∞–≤–∏—Å–∏–º–æ—Å—Ç–∏ –æ—Ç —Ç–æ–≥–æ, –º–æ–∂–Ω–æ –ª–∏ –Ω–∞–π—Ç–∏ —ç—Ç–æ—Ç —Ñ–∞–π–ª. –≠—Ç–æ—Ç –º–µ—Ç–æ–¥ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç –∑–Ω–∞—á–µ–Ω–∏–µ False, –µ—Å–ª–∏ –≤ –∫–∞—á–µ—Å—Ç–≤–µ –∞—Ä–≥—É–º–µ–Ω—Ç–∞ —É–∫–∞–∑–∞–Ω –∫–∞—Ç–∞–ª–æ–≥.

–í–æ—Ç —Å–∏–Ω—Ç–∞–∫—Å–∏—Å –º–µ—Ç–æ–¥–∞ isfile ():

81% —É—á–∞—Å—Ç–Ω–∏–∫–æ–≤ –∑–∞—è–≤–∏–ª–∏, —á—Ç–æ –ø–æ—Å–ª–µ –±—É—Ç–∫–µ–º–ø–∞ –æ–Ω–∏ –ø–æ—á—É–≤—Å—Ç–≤–æ–≤–∞–ª–∏ —Å–µ–±—è –±–æ–ª–µ–µ —É–≤–µ—Ä–µ–Ω–Ω—ã–º–∏ –≤ —Å–≤–æ–∏—Ö –ø–µ—Ä—Å–ø–µ–∫—Ç–∏–≤–∞—Ö —Ç—Ä—É–¥–æ—É—Å—Ç—Ä–æ–π—Å—Ç–≤–∞ –≤ —Å—Ñ–µ—Ä–µ –≤—ã—Å–æ–∫–∏—Ö —Ç–µ—Ö–Ω–æ–ª–æ–≥–∏–π. –ü–æ–ª—É—á–∏—Ç–µ –ø—Ä–∏–≥–ª–∞—à–µ–Ω–∏–µ –Ω–∞ —É—á–µ–±–Ω—ã–π –∫—É—Ä—Å —Å–µ–≥–æ–¥–Ω—è.

–°—Ä–µ–¥–Ω–∏–π –≤—ã–ø—É—Å–∫–Ω–∏–∫ —É—á–µ–±–Ω–æ–≥–æ –ª–∞–≥–µ—Ä—è –ø–æ—Ç—Ä–∞—Ç–∏–ª –º–µ–Ω–µ–µ —à–µ—Å—Ç–∏ –º–µ—Å—è—Ü–µ–≤ –Ω–∞ —Å–º–µ–Ω—É –∫–∞—Ä—å–µ—Ä—ã, –æ—Ç –Ω–∞—á–∞–ª–∞ —É—á–µ–±–Ω–æ–≥–æ –ª–∞–≥–µ—Ä—è –¥–æ –ø–æ–∏—Å–∫–∞ —Å–≤–æ–µ–π –ø–µ—Ä–≤–æ–π —Ä–∞–±–æ—Ç—ã.

isfile () –ø—Ä–∏–Ω–∏–º–∞–µ—Ç –æ–¥–∏–Ω –∞—Ä–≥—É–º–µ–Ω—Ç. : –∏–º—è —Ñ–∞–π–ª–∞, —Å—É—â–µ—Å—Ç–≤–æ–≤–∞–Ω–∏–µ –∫–æ—Ç–æ—Ä–æ–≥–æ –≤—ã —Ö–æ—Ç–∏—Ç–µ –ø—Ä–æ–≤–µ—Ä–∏—Ç—å. " –ø—É—Ç—å " –ø—Ä–µ–¥—Å—Ç–∞–≤–ª—è–µ—Ç –ø—É—Ç—å –∫ —Ñ–∞–π–ª—É –≤ –ø—Ä–∏–≤–µ–¥–µ–Ω–Ω–æ–º –≤—ã—à–µ –ø—Ä–∏–º–µ—Ä–µ. –î–∞–≤–∞–π—Ç–µ —Ä–∞—Å—Å–º–æ—Ç—Ä–∏–º –ø—Ä–∏–º–µ—Ä, —á—Ç–æ–±—ã –ø–æ–∫–∞–∑–∞—Ç—å, –∫–∞–∫ –≤—ã –º–æ–∂–µ—Ç–µ –ø—Ä–æ–≤–µ—Ä–∏—Ç—å, —Å—É—â–µ—Å—Ç–≤—É–µ—Ç –ª–∏ —Ñ–∞–π–ª –≤ Python.

–ü—Ä–æ–≤–µ—Ä–∏—Ç—å, —Å—É—â–µ—Å—Ç–≤—É–µ—Ç –ª–∏ —Ñ–∞–π–ª. –ü—Ä–∏–º–µ—Ä Python

–ü—Ä–µ–¥–ø–æ–ª–æ–∂–∏–º, –º—ã —Å–æ–∑–¥–∞–µ–º –ø—Ä–æ–≥—Ä–∞–º–º—É, –∫–æ—Ç–æ—Ä–∞—è –∞–Ω–∞–ª–∏–∑–∏—Ä—É–µ—Ç –¥–∞–Ω–Ω—ã–µ –æ–± —É—Ä–æ–∂–∞–π–Ω–æ—Å—Ç–∏ –∞–≤–æ–∫–∞–¥–æ –¥–ª—è –º–µ—Å—Ç–Ω–æ–π —Ñ–µ—Ä–º—ã. –ü–µ—Ä–µ–¥ –ø—Ä–æ–≤–µ–¥–µ–Ω–∏–µ–º –Ω–∞—à–µ–≥–æ –∞–Ω–∞–ª–∏–∑–∞ –º—ã —Ö–æ—Ç–∏–º —á—Ç–æ–±—ã –ø—Ä–æ–≤–µ—Ä–∏—Ç—å, –µ—Å—Ç—å –ª–∏ —É –Ω–∞—Å –æ–±—Ä–∞–±–æ—Ç–∞–Ω–Ω—ã–π —Ñ–∞–π–ª, –≤ –∫–æ—Ç–æ—Ä–æ–º –º—ã –º–æ–∂–µ–º —Ö—Ä–∞–Ω–∏—Ç—å –ø—Ä–æ–∞–Ω–∞–ª–∏–∑–∏—Ä–æ–≤–∞–Ω–Ω—ã–µ –¥–∞–Ω–Ω—ã–µ. –ï—Å–ª–∏ —Ñ–∞–π–ª –Ω–µ —Å—É—â–µ—Å—Ç–≤—É–µ—Ç, –Ω–∞–º –Ω—É–∂–Ω–æ –±—É–¥–µ—Ç –µ–≥–æ —Å–æ–∑–¥–∞—Ç—å.

–ù–∞—à –æ–±—Ä–∞–±–æ—Ç–∞–Ω–Ω—ã–π —Ñ–∞–π–ª –¥–æ–ª–∂–µ–Ω –Ω–∞–∑—ã–≤–∞—Ç—å—Å—è . /final_data.csv. –ß—Ç–æ–±—ã –ø—Ä–æ–≤–µ—Ä–∏—Ç—å, —Å—É—â–µ—Å—Ç–≤—É–µ—Ç –ª–∏ —ç—Ç–æ—Ç —Ñ–∞–π–ª, –º–æ–∂–Ω–æ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å —Å–ª–µ–¥—É—é—â–∏–π –∫–æ–¥:

–ï—Å–ª–∏ –Ω–∞—à –ø—É—Ç—å –∫ —Ñ–∞–π–ª—É —Å—É—â–µ—Å—Ç–≤—É–µ—Ç, –Ω–∞—à –∫–æ–¥ –≤–µ—Ä–Ω–µ—Ç –õ–æ–≥–∏—á–µ—Å–∫–æ–µ –∑–Ω–∞—á–µ–Ω–∏–µ Python True. –ï—Å–ª–∏ —Ñ–∞–π–ª–∞ –Ω–µ—Ç (–∏, —Å–ª–µ–¥–æ–≤–∞—Ç–µ–ª—å–Ω–æ, –Ω–µ—Ç –ø—É—Ç–∏ –∫ —Ñ–∞–π–ª—É), –Ω–∞—à –∫–æ–¥ –≤–µ—Ä–Ω–µ—Ç False.

isfile ( ) –º–µ–Ω—è thod —Ä–∞–±–æ—Ç–∞–µ—Ç —Ç–æ–ª—å–∫–æ —Å —Ñ–∞–π–ª–∞–º–∏; —ç—Ç–æ –Ω–µ —Ä–∞–±–æ—Ç–∞–µ—Ç –¥–ª—è –∫–∞—Ç–∞–ª–æ–≥–æ–≤. –ï—Å–ª–∏ –≤—ã –∏—Å–ø–æ–ª—å–∑—É–µ—Ç–µ isfile (), —á—Ç–æ–±—ã –ø—Ä–æ–≤–µ—Ä–∏—Ç—å, —Å—É—â–µ—Å—Ç–≤—É–µ—Ç –ª–∏ –∫–∞—Ç–∞–ª–æ–≥, –º–µ—Ç–æ–¥ –≤–µ—Ä–Ω–µ—Ç False. –í–æ—Ç –ø—Ä–∏–º–µ—Ä –∏—Å–ø–æ–ª—å–∑–æ–≤–∞–Ω–∏—è isfile () –¥–ª—è –ø—Ä–æ–≤–µ—Ä–∫–∏ —Å—É—â–µ—Å—Ç–≤–æ–≤–∞–Ω–∏—è –∫–∞—Ç–∞–ª–æ–≥–∞:

–ù–∞—à –∫–æ–¥ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç: False.

Python Check –µ—Å–ª–∏ –∫–∞—Ç–∞–ª–æ–≥ —Å—É—â–µ—Å—Ç–≤—É–µ—Ç

–ú–µ—Ç–æ–¥ Python os.path.isdir () –ø—Ä–æ–≤–µ—Ä—è–µ—Ç, —Å—É—â–µ—Å—Ç–≤—É–µ—Ç –ª–∏ –∫–∞—Ç–∞–ª–æ–≥. –û–Ω –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç False, –µ—Å–ª–∏ –≤—ã —É–∫–∞–∑—ã–≤–∞–µ—Ç–µ –ø—É—Ç—å –∫ –Ω–µ—Å—É—â–µ—Å—Ç–≤—É—é—â–µ–º—É —Ñ–∞–π–ª—É –∏–ª–∏ –∫–∞—Ç–∞–ª–æ–≥—É. –ï—Å–ª–∏ –∫–∞—Ç–∞–ª–æ–≥ —Å—É—â–µ—Å—Ç–≤—É–µ—Ç, isdir () –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç True.

–í–æ—Ç —Å–∏–Ω—Ç–∞–∫—Å–∏—Å –¥–ª—è –º–µ—Ç–æ–¥–∞ isdir ():

–ú–µ—Ç–æ–¥ isdir () –ø—Ä–∏–Ω–∏–º–∞–µ—Ç –æ–¥–∏–Ω –∞—Ä–≥—É–º–µ–Ω—Ç : –∫–∞—Ç–∞–ª–æ–≥, —Å—É—â–µ—Å—Ç–≤–æ–≤–∞–Ω–∏–µ –∫–æ—Ç–æ—Ä–æ–≥–æ –≤—ã —Ö–æ—Ç–∏—Ç–µ –ø—Ä–æ–≤–µ—Ä–∏—Ç—å.

–ü—Ä–æ–≤–µ—Ä–∏—Ç—å, —Å—É—â–µ—Å—Ç–≤—É–µ—Ç –ª–∏ –∫–∞—Ç–∞–ª–æ–≥. –ü—Ä–∏–º–µ—Ä Python

–î–æ–ø—É—Å—Ç–∏–º, –º—ã —Ö–æ—Ç–∏–º –ø—Ä–æ–≤–µ—Ä–∏—Ç—å, —Å—É—â–µ—Å—Ç–≤—É–µ—Ç –ª–∏ –ø–∞–ø–∫–∞ final_data_folder. –ú—ã –ø–ª–∞–Ω–∏—Ä—É–µ–º –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å —ç—Ç–æ—Ç –∫–∞—Ç–∞–ª–æ–≥ –¥–ª—è —Ö—Ä–∞–Ω–µ–Ω–∏—è –¥–∞–Ω–Ω—ã—Ö, –æ–±—Ä–∞–±–æ—Ç–∞–Ω–Ω—ã—Ö –Ω–∞—à–µ–π –ø—Ä–æ–≥—Ä–∞–º–º–æ–π –∞–Ω–∞–ª–∏–∑–∞ –¥–∞–Ω–Ω—ã—Ö –∞–≤–æ–∫–∞–¥–æ.

–ú—ã –º–æ–≥–ª–∏ –±—ã –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å —Å–ª–µ–¥—É—é—â–∏–π –∫–æ–¥, —á—Ç–æ–±—ã –ø—Ä–æ–≤–µ—Ä–∏—Ç—å, —Å—É—â–µ—Å—Ç–≤—É–µ—Ç –ª–∏ —ç—Ç–æ—Ç –∫–∞—Ç–∞–ª–æ–≥:

–ù–∞—à –∫–∞—Ç–∞–ª–æ–≥ –¥–µ–π—Å—Ç–≤–∏—Ç–µ–ª—å–Ω–æ —Å—É—â–µ—Å—Ç–≤—É–µ—Ç, –ø–æ—ç—Ç–æ–º—É –Ω–∞—à–∞ –ø—Ä–æ–≥—Ä–∞–º–º–∞ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç True.

–ï—Å–ª–∏ –≤—ã –ø–æ–ø—ã—Ç–∞–µ—Ç–µ—Å—å –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å isdir (), —á—Ç–æ–±—ã –ø—Ä–æ–≤–µ—Ä–∏—Ç—å, —Å—É—â–µ—Å—Ç–≤—É–µ—Ç –ª–∏ —Ñ–∞–π–ª, –º–µ—Ç–æ–¥ –≤–µ—Ä–Ω–µ—Ç False . –≠—Ç–æ –ø–æ—Ö–æ–∂–µ –Ω–∞ —Ç–æ, –∫–∞–∫ –º–µ—Ç–æ–¥ isfile () —Ä–µ–∞–≥–∏—Ä—É–µ—Ç –Ω–∞ –∫–∞—Ç–∞–ª–æ–≥–∏.

–ü—Ä–æ–≤–µ—Ä–∫–∞ –Ω–∞–ª–∏—á–∏—è –æ–ø—Ä–µ–¥–µ–ª–µ–Ω–Ω–æ–≥–æ —Ñ–∞–π–ª–∞ –∏–ª–∏ –∫–∞—Ç–∞–ª–æ–≥–∞ –≤ Python

–í Python –≤—ã –º–æ–∂–µ—Ç–µ –ø—Ä–æ–≤–µ—Ä–∏—Ç—å, —Å—É—â–µ—Å—Ç–≤—É—é—Ç –ª–∏ –æ–ø—Ä–µ–¥–µ–ª–µ–Ω–Ω—ã–µ —Ñ–∞–π–ª—ã –∏–ª–∏ –∫–∞—Ç–∞–ª–æ–≥–∏, –∏—Å–ø–æ–ª—å–∑—É—è isfile () –∏ isdir () —Å–æ–æ—Ç–≤–µ—Ç—Å—Ç–≤–µ–Ω–Ω–æ.

–û–¥–Ω–∞–∫–æ, –µ—Å–ª–∏ –≤—ã –∏—Å–ø–æ–ª—å–∑—É–µ—Ç–µ isfile () –¥–ª—è –ø—Ä–æ–≤–µ—Ä–∫–∏, —Å—É—â–µ—Å—Ç–≤—É–µ—Ç –ª–∏ –æ–ø—Ä–µ–¥–µ–ª–µ–Ω–Ω—ã–π –∫–∞—Ç–∞–ª–æ–≥, –º–µ—Ç–æ–¥ –≤–µ—Ä–Ω–µ—Ç False. –ê–Ω–∞–ª–æ–≥–∏—á–Ω—ã–º –æ–±—Ä–∞–∑–æ–º, –µ—Å–ª–∏ –≤—ã –∏—Å–ø–æ–ª—å–∑—É–µ—Ç–µ if isdir () –¥–ª—è –ø—Ä–æ–≤–µ—Ä–∫–∏ —Å—É—â–µ—Å—Ç–≤–æ–≤–∞–Ω–∏—è –æ–ø—Ä–µ–¥–µ–ª–µ–Ω–Ω–æ–≥–æ —Ñ–∞–π–ª–∞, –º–µ—Ç–æ–¥ –≤–µ—Ä–Ω–µ—Ç False.

–ù–æ —á—Ç–æ, –µ—Å–ª–∏ –≤—ã —Ö–æ—Ç–∏—Ç–µ –ø—Ä–æ–≤–µ—Ä–∏—Ç—å, —Å—É—â–µ—Å—Ç–≤—É–µ—Ç –ª–∏ –æ–ø—Ä–µ–¥–µ–ª–µ–Ω–Ω—ã–π —Ñ–∞–π–ª –∏–ª–∏ –∫–∞—Ç–∞–ª–æ–≥? –í—ã –º–æ–∂–µ—Ç–µ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å –º–µ—Ç–æ–¥ os.path.exists () –¥–ª—è –≤—ã–ø–æ–ª–Ω–µ–Ω–∏—è —ç—Ç–æ–≥–æ –¥–µ–π—Å—Ç–≤–∏—è .

–ü—Ä–µ–¥–ø–æ–ª–æ–∂–∏–º, –≤—ã —Ö–æ—Ç–∏—Ç–µ —É–∑–Ω–∞—Ç—å, —Å—É—â–µ—Å—Ç–≤—É–µ—Ç –ª–∏ —Ñ–∞–π–ª ./final_data_2020.csv. –í—ã –º–æ–∂–µ—Ç–µ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å —Å–ª–µ–¥—É—é—â–∏–π –∫–æ–¥, —á—Ç–æ–±—ã –ø—Ä–æ–≤–µ—Ä–∏—Ç—å, —Å—É—â–µ—Å—Ç–≤—É–µ—Ç –ª–∏ —ç—Ç–æ—Ç —Ñ–∞–π–ª:

–ù–∞—à —Ñ–∞–π–ª —Å—É—â–µ—Å—Ç–≤—É–µ—Ç, –ø–æ—ç—Ç–æ–º—É –Ω–∞—à–∞ –ø—Ä–æ–≥—Ä–∞–º–º–∞ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç True.

"–ö–∞—Ä—å–µ—Ä–∞ –ö–∞—Ä–º–∞ –≤–æ—à–ª–∞ –≤ –º–æ—é –∂–∏–∑–Ω—å, –∫–æ–≥–¥–∞ —è –±–æ–ª—å—à–µ –≤—Å–µ–≥–æ –≤ –Ω–µ–π –Ω—É–∂–¥–∞–ª–∞—Å—å, –∏ –±—ã—Å—Ç—Ä–æ –ø–æ–º–æ–≥–ª–∞ –º–Ω–µ –ø—Ä–æ–π—Ç–∏ –∫—É—Ä—Å –±—É—Ç–∫–µ–º–ø–∞. –ß–µ—Ä–µ–∑ –¥–≤–∞ –º–µ—Å—è—Ü–∞ –ø–æ—Å–ª–µ –≤—ã–ø—É—Å–∫–∞ —è –Ω–∞—à–ª–∞ —Ä–∞–±–æ—Ç—É —Å–≤–æ–µ–π –º–µ—á—Ç—ã, –∫–æ—Ç–æ—Ä–∞—è —Å–æ–æ—Ç–≤–µ—Ç—Å—Ç–≤–æ–≤–∞–ª–∞ –º–æ–∏–º —Ü–µ–Ω–Ω–æ—Å—Ç—è–º –∏ —Ü–µ–ª—è–º –≤ –∂–∏–∑–Ω–∏! "

–í–µ–Ω–µ—Ä–∞, –∏–Ω–∂–µ–Ω–µ—Ä-–ø—Ä–æ–≥—Ä–∞–º–º–∏—Å—Ç –≤ Rockbot

< p> –ö—Ä–æ–º–µ —Ç–æ–≥–æ, –µ—Å–ª–∏ –º—ã —Ö–æ—Ç–∏–º –ø—Ä–æ–≤–µ—Ä–∏—Ç—å, —Å—É—â–µ—Å—Ç–≤—É–µ—Ç –ª–∏ –∫–∞—Ç–∞–ª–æ–≥ ./final_data, –º—ã —Ç–∞–∫–∂–µ –º–æ–∂–µ–º –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å –¥–ª—è —ç—Ç–æ–≥–æ os.path.exists () —Å–ª–µ–¥—É—é—â–∏–º –æ–±—Ä–∞–∑–æ–º:

–ù–∞—à –∫–∞—Ç–∞–ª–æ–≥ final_data —Å—É—â–µ—Å—Ç–≤—É–µ—Ç –≤ –Ω–∞—à–µ–º –ø—Ä–∏–º–µ—Ä–µ, –ø–æ—ç—Ç–æ–º—É –Ω–∞—à –∫–æ–¥ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç True.

–ó–∞–∫–ª—é—á–µ–Ω–∏–µ

–ö–æ–≥–¥–∞ –≤—ã " re —Ä–∞–±–æ—Ç–∞—è –≤ Python, –≤—ã –º–æ–∂–µ—Ç–µ –ø—Ä–æ–≤–µ—Ä–∏—Ç—å, —Å—É—â–µ—Å—Ç–≤—É—é—Ç –ª–∏ –æ–ø—Ä–µ–¥–µ–ª–µ–Ω–Ω—ã–µ —Ñ–∞–π–ª—ã –∏ / –∏–ª–∏ –∫–∞—Ç–∞–ª–æ–≥–∏, –ø—Ä–µ–∂–¥–µ —á–µ–º —Ä–∞–∑—Ä–µ—à–∏—Ç—å –≤—ã–ø–æ–ª–Ω–µ–Ω–∏–µ –≤–∞—à–µ–π –ø—Ä–æ–≥—Ä–∞–º–º—ã. isfile (), isdir () –∏ –≠—Ç–æ –º–æ–∂–Ω–æ —Å–¥–µ–ª–∞—Ç—å —Å –ø–æ–º–æ—â—å—é –º–µ—Ç–æ–¥–æ–≤ exists ().

–í —Å–ª–µ–¥—É—é—â–µ–π —Ç–∞–±–ª–∏—Ü–µ –ø–æ–∫–∞–∑–∞–Ω–æ, –∫–æ–≥–¥–∞ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å –∫–∞–∫—É—é —Ñ—É–Ω–∫—Ü–∏—é –≤ Python —Å–ª–µ–¥—É–µ—Ç –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å, —á—Ç–æ–±—ã –æ–ø—Ä–µ–¥–µ–ª–∏—Ç—å, —Å—É—â–µ—Å—Ç–≤—É—é—Ç –ª–∏ –æ–ø—Ä–µ–¥–µ–ª–µ–Ω–Ω—ã–µ —Ñ–∞–π–ª—ã –∏–ª–∏ –∫–∞—Ç–∞–ª–æ–≥–∏:

–§—É–Ω–∫—Ü–∏—è –ß—Ç–æ –æ–ø—Ä–µ–¥–µ–ª—è–µ—Ç —Ñ—É–Ω–∫—Ü–∏—è
os.path.isfile (" file ") –ò–º–µ–µ—Ç –ª–∏ " file " —Å—É—â–µ—Å—Ç–≤—É–µ—Ç?
os.path.isdir (" directory ") –ï—Å—Ç—å –ª–∏ –≤ " directory " —Å—É—â–µ—Å—Ç–≤—É—é—Ç?
os.path.exists (" —Ñ–∞–π–ª / –∫–∞—Ç–∞–ª–æ–≥ ") –ò–º–µ–µ—Ç –ª–∏ " —Ñ–∞–π–ª / –∫–∞—Ç–∞–ª–æ–≥ " exist?

–ü–æ–º–Ω–∏—Ç–µ, —á—Ç–æ –ø–µ—Ä–µ–¥ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞–Ω–∏–µ–º —ç—Ç–∏—Ö —Ñ—É–Ω–∫—Ü–∏–π –≤–∞–º —Å–Ω–∞—á–∞–ª–∞ –Ω—É–∂–Ω–æ –∏–º–ø–æ—Ä—Ç–∏—Ä–æ–≤–∞—Ç—å –º–æ–¥—É–ª—å —Ç–æ—á–∫–∏ –ø—É—Ç–∏ os –¥–ª—è Python. –î–ª—è —ç—Ç–æ–≥–æ –∏—Å–ø–æ–ª—å–∑—É–π—Ç–µ —Å–ª–µ–¥—É—é—â–∏–π –∫–æ–¥: import os.path.

–ü—Ä–æ—á—Ç–∏—Ç–µ –Ω–∞—à –ö–∞–∫ –∏–∑—É—á–∏—Ç—å Python —Å—Ç–∞—Ç—å—é —Å —Å–æ–≤–µ—Ç–∞–º–∏ –æ —Ç–æ–º, –∫–∞–∫ –ø—Ä–∏–æ–±—Ä–µ—Å—Ç–∏ –Ω–∞–≤—ã–∫–∏, –Ω–µ–æ–±—Ö–æ–¥–∏–º—ã–µ –¥–ª—è –æ—Å–≤–æ–µ–Ω–∏—è Python.