Difference between revisions of "Code Snippet: Read File"
From Coder Merlin
Line 1: | Line 1: | ||
= Read the contents of a file into a string = | |||
== Swift == | |||
<syntaxhighlight lang="swift"> | <syntaxhighlight lang="swift"> | ||
import Foundation | import Foundation | ||
Line 5: | Line 7: | ||
let contents = try! String(contentsOfFile: "hello.txt") | let contents = try! String(contentsOfFile: "hello.txt") | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== Python == |