|
Oktatás * Programozás 1 * Szkriptnyelvek Teaching * Programming 1 (BI) Félévek Linkek * kalendárium |
Nim2 /
StringVery similar to Python. let text = "hello world" path = r"C:\Program files\Notepad++" html = """ <title>Nim</title> <h1>hello</h1> """ echo text echo "" echo path echo "" echo "'" & html & "'" Output: hello world C:\Program files\Notepad++ '<title>Nim</title> <h1>hello</h1> ' Notice that the multiline string behaves a bit differently from Python. The leading newline character is not present. This is actually intentional Nim behavior — Nim's triple-quoted strings strip the first newline if it immediately follows the opening StripIf you don't need the leading and trailing whitespaces, just strip it: import std/strutils # strip, split, join let html = """ <title>Nim</title> <h1>hello</h1> """.strip echo "'" & html & "'" '<title>Nim</title> <h1>hello</h1>' |
![]() Blogjaim, hobbi projektjeim * The Ubuntu Incident [ edit ] |