File needs to be in read mode

This commit is contained in:
Hamel Husain 2020-12-16 12:36:13 -08:00 committed by GitHub
parent a3f5609202
commit ab6f9f97a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -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)