mirror of https://github.com/Textualize/rich.git
File needs to be in read mode
This commit is contained in:
parent
a3f5609202
commit
ab6f9f97a3
|
@ -9,7 +9,7 @@ To syntax highlight code, construct a :class:`~rich.syntax.Syntax` object and pr
|
||||||
from rich.syntax import Syntax
|
from rich.syntax import Syntax
|
||||||
|
|
||||||
console = Console()
|
console = Console()
|
||||||
with open("syntax.py", "wt") as code_file:
|
with open("syntax.py", "rt") as code_file:
|
||||||
syntax = Syntax(code_file.read(), "python")
|
syntax = Syntax(code_file.read(), "python")
|
||||||
console.print(syntax)
|
console.print(syntax)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue