Python Archivo grabable () Método : Aquí, vamos a aprender sobre el método (), se puede escribir cómo comprobar si un archivo se puede escribir o no en Python?
puede escribir archivos () Método
grabable () método es un método incorporado en Python, que se utiliza para comprobar si una secuencia de archivo se puede escribir o no en Python?
Sintaxis:
file_object.writable()
Parámetro (s):
- No acepta ningún parámetro.
class valor:
El tipo Return de este método es & lt; return ‘bool’ & gt; , devuelve Verdadero si secuencia de archivo se puede escribir y vuelve Falso si los archivos no se puede escribir.
Ejemplo:
# Python File writable() Method with Example
# creating a file
myfile1 = open("hello1.txt", "w")
# checking whethet the file stream is
# writable or not
print("myfile1.writable():", myfile1.writable())
# closing the file
myfile1.close()
# opening file in read mode
myfile1 = open("hello1.txt", "r")
# checking whethet the file stream is
# writable or not
print("myfile1.writable():", myfile1.writable())
# closing the file
myfile1.close()
salida
myfile1.writable(): True
myfile1.writable(): False