>>> help(set)
Python 3.10.5 (main, Aug 1 2022, 07:53:20) [GCC 12.1.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.4.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: set?
Init signature: set(self, /, *args, **kwargs)
Docstring:
set() -> new empty set object
set(iterable) -> new set object
Build an unordered collection of unique elements.
Type: type
Subclasses:
In [2]: %pdef set
No definition header found for set
In [3]: %pdoc set
Class docstring:
set() -> new empty set object
set(iterable) -> new set object
Build an unordered collection of unique elements.
Init docstring:
Initialize self. See help(type(self)) for accurate signature.
In [4]: %psource set
No source found for set
// через методы строки .bold() и .italics()
var html = "Понедельник".italics(); // html==='<i>Понедельник</i>';
var html = "Суббота".bold(); // html==='<b>Суббота</b>';
// вручную собрать строку
var dow = 'Понедельник';
var html = '<i>' + dow + '</i>'; // html==='<i>Понедельник</i>';
// то же самое в обратных кавычках
var dow = 'Понедельник';
var html = `<i>${dow}</i>`; // html==='<i>Понедельник</i>';
document.write()
– плохая практика, не надо его.const week = ['Понедельник', 'Вторник', 'Среда', 'Четверг', 'Пятница', 'Суббота', 'Воскресенье'];
for (let i = 0, len = week.length; i < len; i++) {
let html = week[i];
if (i === 0) html = html.italics(); // понедельник
else if (i > 4) html = html.bold(); // выходные
const div = document.createElement('div');
div.innerHTML = html;
document.body.appendChild(div);
}
import subprocess
subprocess.run(["firefox"])
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0
import time
# Create a new instance of the Firefox driver
driver = webdriver.Firefox()
# go to the google home page
driver.get("http://www.google.com")
# find the element that's name attribute is q (the google search box)
inputElement = driver.find_element_by_name("q")
# type in the search
inputElement.send_keys("Cheese!")
# submit the form (although google automatically searches now without submitting)
inputElement.submit()
# the page is ajaxy so the title is originally this:
print driver.title
try:
# we have to wait for the page to refresh, the last thing that seems to be updated is the title
WebDriverWait(driver, 10).until(lambda driver : driver.title.lower().startswith("cheese!"))
# You should see "cheese! - Google Search"
print driver.title
finally:
driver.quit()
import random
b = ["Каменный ", "Чистый ", "Кристальный "]
a = ["Меч", "Карандаш", "Зуб"]
print(f"{a[random.randint(0,2)]} {b[random.randint(0,2)]}")
import random
b = ["Каменный ", "Чистый ", "Кристальный "]
a = ["Меч", "Карандаш", "Зуб"]
for _ in range(len(a)):
print(f"{a[random.randint(0,2)]} {b[random.randint(0,2)]}")
In [1]: from urllib.parse import urlparse
In [2]: o = urlparse('https://site.ru/images/favicon.ico?foo=bar')
In [3]: o
Out[3]: ParseResult(scheme='https', netloc='site.ru', path='/images/favicon.ico', params='', query='foo=bar', fragment='')
In [4]: o.path.split('/')[-1]
Out[4]: 'favicon.ico'
class Post(models.Model):
title = models.CharField(max_lenth=50)
next_posts = models.ManyToManyField('self', related_name='prev_posts', symmetrical=False, blank=True)