В гугле есть один,
Почему в двумерном массиве каждый подмассив становится копией другого
Assignment statements in Python do not copy objects, they create bindings between a target and an object. For collections that are mutable or contain mutable items, a copy is sometimes needed so one can change one copy without changing the other. This module provides generic shallow and deep copy operations (explained below).
new_list = old_list.copy()
# или
new_list = old_list[:]
import copy
new_list = copy.deepcopy(old_list)
Как отключить проверку SSL в телеграмм боте?
import boto3
from botocore.exceptions import ClientError
def upload_file(file_name, bucket, object_name=None):
"""Upload a file to an S3 bucket
:param file_name: File to upload
:param bucket: Bucket to upload to
:param object_name: S3 object name. If not specified then file_name is used
:return: True if file was uploaded, else False
"""
# If S3 object_name was not specified, use file_name
if object_name is None:
object_name = file_name
# Upload the file
s3_client = boto3.client('s3')
try:
response = s3_client.upload_file(file_name, bucket, object_name)
except ClientError as e:
logging.error(e)
return False
return True
import logging
import boto3
from botocore.exceptions import ClientError
def create_presigned_url(bucket_name, object_name, expiration=3600):
"""Generate a presigned URL to share an S3 object
:param bucket_name: string
:param object_name: string
:param expiration: Time in seconds for the presigned URL to remain valid
:return: Presigned URL as string. If error, returns None.
"""
# Generate a presigned URL for the S3 object
s3_client = boto3.client('s3')
try:
response = s3_client.generate_presigned_url('get_object',
Params={'Bucket': bucket_name,
'Key': object_name},
ExpiresIn=expiration)
except ClientError as e:
logging.error(e)
return None
# The response contains the presigned URL
return response
import pandas as pd
import matplotlib.pyplot as plt
data_file = 'gapminder-FiveYearData.csv'
gapminder = pd.read_csv(data_file)
gapminder.head(n=3)
gapminder['lifeExp'].hist(bins=100)
plt.show()
import numpy as np
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
x = [21,22,23,4,5,6,77,8,9,10,31,32,33,34,35,36,37,18,49,50,100]
num_bins = 5
n, bins, patches = plt.hist(x, num_bins, facecolor='blue', alpha=0.5)
plt.show()
POST-ом забирать данные, пробрасывать их до внешнего сервера GET-ом и возвращать ответ на форму.
Можете скинуть пример реализации?
class YouView(View):
def post(self, request):
you_data_1 = request.POST.get("youData1")
you_data_2 = request.POST.get("youData2")
you_data_3 = request.POST.get("youData3")
arr.sort([compareFunction])
А если текущий и следующий элемент в середине массива, то как они сравниваются с теми что были в начале?
const array = [25, 8, 7, 41, 1, 3];
array.sort((a,b) => {
console.log(`compare ${a},${b}`);
return a > b ? 1 : a === b ? 0 : -1;
});
compare 25,8
compare 25,7
compare 8,7
compare 25,41
compare 41,1
compare 25,1
compare 8,1
compare 7,1
compare 41,3
compare 25,3
compare 8,3
compare 7,3
compare 1,3
[ 1, 3, 7, 8, 25, 41 ]
CREATE TABLE qna
(
name VARCHAR(30) NOT NULL CHECK (name IN ('registrator', 'coordinator', 'user'))
);
from Tkinter import *
master = Tk()
def callback():
print "click!"
b = Button(master, text="OK", command=callback)
b.pack()
mainloop()
root.configure(background='black')
import tkinter as tk
from tkinter import *
стоит задача создать приложения для компьютера, которое отправляет посты во вконтакте, и при отправке каждого поста у юзера обновляется значение в базе данных на единицу.то зачем
создать api и работать с ним через код программы
<ul class="nav navbar-nav navbar-right">
<li {{ home_active }}><a href="/">Home</a></li>
<li {{ places_active }}><a href="/places">Places</a></li>
</ul>
@app.route('/')
@app.route('/home')
def index():
return render_template('index.html', home_active="class=active")
@app.route('/places')
def map():
return render_template('places.html', places_active="class=active")
def some_view():
return render_template('template.html', active='home')
<li class="{% if active=='home' %}active{%endif %}">Home</li>
<li class="{% if active=='blog' %}active{%endif %}">Blog</li>
{% extends "layout.html" %}
{% set active_page = "index" %}
{% set navigation_bar = [
('/', 'index', 'Index'),
('/downloads/', 'downloads', 'Downloads'),
('/about/', 'about', 'About')
] -%}
{% set active_page = active_page|default('index') -%}
...
<ul id="navigation">
{% for href, id, caption in navigation_bar %}
<li{% if id == active_page %} class="active"{% endif
%}><a href="{{ href|e }}">{{ caption|e }}</a></li>
{% endfor %}
</ul>