“Penanganan file” Kode Jawaban

Penanganan file

// 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

File Python terbuka

#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

Penanganan file

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

Jawaban yang mirip dengan “Penanganan file”

Pertanyaan yang mirip dengan “Penanganan file”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya