Как правильно проверить атрибуты доступа файла? То есть доступна ли запись в файл или является ли он исполняемым?
Для этого в 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
¿Que puede hacer este bot?
@ButtonMakerXBot
Envíe un medio o un mensaje de texto y agregue botones de acuerdo con su deseo y compártalo en todo TG
Idioma inglés
(Visto en @botsgram_cu)
#botones
Debido a que las reacciones de Telegram llegarán en la próxima actualización, puede optar por 2 métodos de reacciones: reacciones nativas de Telegram o bots de #botones de reacción.
(Visto en @BotsGram_cu)
¿Que puede hacer este bot?
@SuperEmojiBot
Agregue automáticamente botones de reacción y compartir a las publicaciones en su canal.
Idiomas: ruso, inglés, uzbeko
(Visto en @botsgram_cu)
#botones#canales
¿Que puede hacer este bot?
@RemoveInlineButtonsBot
Este bot eliminará cualquier mensaje que contenga botones en línea en grupos o canales
Idiomas: inglés árabe
(Visto en @botsgram_cu)
#botones#inlinebuttons
@ChannelButtonsBot
Qué puede hacer este bot?
Este bot puede crear botones para reacciones, comentarios, enlaces y más en su canal de Telegram.
Idioma: Inglés
(visto en @BotsGram_cu)
#canal, #botones, #reacciones
¿Que puede hacer este bot?
@ReactBot
Con éste bot puedes agregar botones de comentarios a las publicaciones de su canal
Idiomas: inglés
(visto en @botsgram_cu)
#canales#botones#comentarios#administrador