Avatar ·

What are commit, connection, cursor, and close for?

📁 iterator, Advanced Python Topics, example

Basic example

import psycopg2# Connect to an existing databaseconn = psycopg2.connect(""dbname=test user=postgres"")# Open a cursor to perform database operationscur = conn.cursor()# Execute a command: this creates a new tablecur.execute(""CREATE TABLE test (id serial PRIMARY KEY, num integer, data varchar);"")# Pass data to fill a query placeholders and let Psycopg perform# the correct conversion (no more SQL injections!)cur.execute(""INSERT INTO test (num, data) VALUES (%s, %s)"",...      (100, ""abc'def""))# Query the dat
Avatar ·

try this:

list_of_words = [    ""The weather is good."",        ""Hot dog is the best food,""    ""it would be a sure sign that it was still yummy."",        ""The girls are beautiful."",        ""Any text, doesn't matter, but after backslash there's a huge ""    ""distance between words. How to fix this?""]print(*list_of_words)print()print(*list_of_words, sep='')

Log in to leave an answer

Blogs