“Obsługa plików” Kod odpowiedzi

Obsługa plików

// basic file operations
#include <iostream>
#include <fstream>
using namespace std;

int main () {
  ofstream myfile;
  myfile.open ("example.txt");
  myfile << "Writing this to a file.\n";
  myfile.close();
  return 0;
}
White Spoonbill

Plik Python otwarty

#there are many modes you can open files in. r means read.
file = open('C:\Users\yourname\files\file.txt','r')
text = file.read()

#you can write a string to it, too!
file = open('C:\Users\yourname\files\file.txt','w')
file.write('This is a typical string')

#don't forget to close it afterwards!
file.close()
Dr. Hippo

Obsługa plików

[file example.txt]
Writing this to a file.
Said HR

Odpowiedzi podobne do “Obsługa plików”

Pytania podobne do “Obsługa plików”

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu