Как правильно проверить атрибуты доступа файла? То есть доступна ли запись в файл или является ли он исполняемым?
Для этого в Python есть функция os.access()
Проверять так:
os.access(path, flag)
Функция вернёт bool в зависимости от наличия указанного флага.
Всего есть 4 флага проверки:
os.F_OK - наличие файла на диске
os.R_OK - доступ на чтение
os.W_OK - доступ на запись
os.X_OK - доступ на исполнение
Например, вместо try-except лучше делать так (пример из документации):
if os.access("myfile", os.R_OK):
with open("myfile") as fp:
return fp.read()
#basic#libs
🔰Airdrop: MetaFish
💸Value: 200 Million $MTF($150)
🪐Referral: 40 Million Each #MTF ($30)
⏳Distribution Date: 15th August 2023
💎Ratings: ⭐️⭐️⭐️⭐️⭐️
🔗Airdrop Link: http://t.me/metafishRound2Airdropbot
Note: Airdrop will end on 15th August 2023 and rewards will be distributed to the winners BEP-20 wallet on after Instantly
Disclaimer: Please do your own research (DYOR) before joining to any airdrops project, also airdrop is 100% free. Don't send any fee or penny for receiving airdrop tokens. Also we don't recommend you to invest in any new projects, just join airdrop for free
💧Airdrop : MetaFish💧
📣Complete Task: ➕ 80,000 #MTF (~$60)
📊Referral: ➕ 20,000 #MTF (~$15)
🏆Winners: All Valid users.
💎Ratings: ⭐️⭐️⭐️
📅End Date: 9th Aug, 2022
🔛Metafish Airdrop For Click Here🔛
🌀 Join Metafish Telegram Group & Telegram Channel.
🌀 Join Advertiser Telegram Group & Telegram Channel.
🌀 Follow Advertiser on Twitter and retweet the pinned post.
🌀 Submit Polygon address
📡Enter your information to the airdrop bot.
🗞Note: All airdrop steps should be completed.
✔️Business Inquiry: Admin or Admin2