“Lea un archivo python” Código de respuesta

Python hace un archivo txt

file = open("text.txt", "w") 
file.write("Your text goes here") 
file.close() 
'r' open for reading (default)
'w' open for writing, truncating the file first
'x' open for exclusive creation, failing if the file already exists
'a' open for writing, appending to the end of the file if it exists
Kodi4444

Python escribir en el archivo

file = open(“testfile.txt”,”w”) 
 
file.write(“Hello World”) 
file.write(“This is our new text file”) 
file.write(“and this is another line.”) 
file.write(“Why? Because we can.”) 
 
file.close() 
Misty Macaw

archivo de lectura de Python

with open("file.txt", "r") as txt_file:
  return txt_file.readlines()
Supermavster

archivo de lectura de Python

txt = open('FILENAME.txt')
txtread = txt.read()
print(txtread)
print(txt.read())
RetroCoder

archivo de lectura de Python

l_a=[]
l_m=[]
l_w=[]
with open("spots.txt","r") as file:
    line=file.readlines()
    for i in range(0,len(line),1):
        [a,m,w]=line[i].split()
        l_a.append(float(a))
        l_m.append(float(m))
        l_w.append(float(w))
Uptight Unicorn

Lea un archivo python

api_key = open(r'path/sanbox_api.txt').read()
Hutch Polecat

Respuestas similares a “Lea un archivo python”

Preguntas similares a “Lea un archivo python”

Más respuestas relacionadas con “Lea un archivo python” en Python

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código