This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://s3.amazonaws.com/codecademy-blog/assets/ae09140c.png |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
При описании синтаксиса команд мы, как правило, используем те же обозначения, | |
что и в интерактивном руководстве: | |
• текст, заключенный в квадратные скобки (“[” и “]”), является необязательным; | |
• текст, после которого стоит многоточие (“...”), можно повторять; | |
• фигурные скобки (“{” и “}”) указывают на то, что необходимо выбрать один из | |
элементов, разделенных вертикальной чертой (“|”). | |
Например, спецификации | |
bork [—х] {on|off} имя_файла... | |
соответствует любая из следующих команд: | |
bork on /etc/passwd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nohup python3 file.py & |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get install sqlite3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlite3 | |
conn = sqlite3.connect('base.db') | |
c = conn.cursor() | |
while True: | |
a = input('\nДобавить запись: a \nУдалить: d INT\nВыход: b\n> ') | |
if a == 'a': |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlite3 | |
conn = sqlite3.connect('base.db') # Название файла БД | |
c = conn.cursor() | |
c.execute('''create table users | |
(id int, nick text, login text)''') # Создали таблицу users с полями ID, NICK, LOGIN | |
# Сохраняем изменения | |
conn.commit() | |
c.close() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def change_case(string): | |
""" | |
На входе: "how can mirrors be real if our eyes aren't real" | |
Должны получить: "How Can Mirrors Be Real If Our Eyes Aren't Real" | |
Получим на самом деле: "How Can Mirrors Be Real If Our Eyes Aren'T Real" | |
""" | |
return string.title() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import string | |
def toJadenCase(NonJadenStrings): | |
return string.capwords(NonJadenStrings) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Hij: | |
attr = 1 | |
hij_var = Hij() | |
hij_var.attr = 2 | |
hij_var.__dict__ # => {'attr': 2} | |
############################################################################### | |
class Abc: | |
__slots__ = ["some_attr"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Для ренджей в раст реализован IntoIter, а итератор коллекционируется в вектор функцией collect: | |
let arr: Vec<u8> = (0..200).into_iter().collect(); | |
//причем итераторы в раст ленивые, т.е. (0..200).into_iter() ≡ xrange(200), | |
//а (0..200).into_iter().collect() ≡ list(xrange(200)). | |
//Если ты имел ввиду list comprehensions из python, то было что-то такое на базе макросов, но нестрого говоря это лишь сахар над map и filter. | |
//Питоновский пример: | |
//M = [x**2 for x in range(10) if x % 2 == 0] | |
//будет выглядеть так: | |
let m: Vec<u8> = (0..10).into_iter().filter(|x| x % 2 == 0).map(|x| x * x).collect(); |
OlderNewer