# Create a new deckdeck = genanki.Deck( 2059400110, 'Example Deck')# Create a model with the name "SimpleModel"model = genanki.Model( 1607392319, 'SimpleModel', fields=[ {'name': 'Question'}, {'name': 'Answer'}, ], templates=[ { 'name': 'Card 1', 'qfmt': '{{Question}}', 'afmt': '{{FrontSide}}<hr id="answer">{{Answer}}', }, ])# Add the model to the deckdeck.add_model(model)# Create a new notenote = genanki.Note( model=model, fields=['Capital of Argentina', 'Buenos Aires'])# Add the note to the deckdeck.add_note(note)# Create a packagegenanki.Package(deck).write_to_file('example.apkg')print("Deck created successfully!")
Deck created successfully!
# Load the deck from the filedeck = genanki.Deck('example.apkg')print("Deck loaded!")# Get the first note from the deckprint(deck.notes)