This PEP proposes the introduction of a new built-in type, bool, with two constants, False and True. The bool type would be a straightforward subtype (in C) of the int type, and the values False and True would behave like 0 and 1 in most respects (for example, False==0 and True==1 would be true) except repr() and str(). All built-in operations that conceptually return a Boolean result will be changed to return False or True instead of 0 or 1; for example, comparisons, the "not" operator, and predicates like isinstance().
total_pages = int(soup.find('div', {'class': 'page_listing'}).findAll('a')[-1].text)
base_url = 'https://www.citilink.ru/catalog/computers_and_notebooks/computers/?available=1&status=55395790&p={}'
urls = [base_url.format(x) for x in range (1, total_pages+1)]
>>> def correct_sentence(text: str) -> str:
... text = text.capitalize()
... if text.endswith('.'):
... return text
... return '{}.'.format(text)
...
>>> print(correct_sentence('greetings, friends'))
Greetings, friends.
>>> print(correct_sentence('greetings, friends.'))
Greetings, friends.
import sqlite3
import csv
conn = sqlite3.connect("test.db")
cur = conn.cursor()
cur.execute("select * from test")
res = cur.fetchall()
res_dict = {key: value for (value, key) in res}
with open('test.csv', 'r') as f:
data = [x for x in csv.reader(f)]
new_data = []
for row in data:
new_row = []
for col in row:
try:
new_col = res_dict[col]
except:
new_col = col
new_row.append(new_col)
new_data.append(new_row)
with open('test2.csv', 'w') as f:
w = csv.writer(f)
w.writerows(new_data)