!$connection->set_charset("utf8")
<?php
$config = array(
'db' => array(
'server' => '#',
'username' => '#',
'password' => '#',
'name' => '#',
)
);
$connection = mysqli_connect(
$config['db']['server'],
$config['db']['username'],
$config['db']['password'],
$config['db']['name']
);
if ($connection == false) {
echo "Немає з'єднання";
echo mysqli_connect_error();
exit();
}
!$connection->set_charset("utf8")
?>
writer = pd.ExcelWriter(f'{os.path.join(graphs_dir, f"{i}.xlsx")}', engine='openpyxl', mode='a')
def append_df_to_excel(filename, df, sheet_name='Sheet1', startrow=None,
truncate_sheet=False,
**to_excel_kwargs):
"""
Append a DataFrame [df] to existing Excel file [filename]
into [sheet_name] Sheet.
If [filename] doesn't exist, then this function will create it.
Parameters:
filename : File path or existing ExcelWriter
(Example: '/path/to/file.xlsx')
df : dataframe to save to workbook
sheet_name : Name of sheet which will contain DataFrame.
(default: 'Sheet1')
startrow : upper left cell row to dump data frame.
Per default (startrow=None) calculate the last row
in the existing DF and write to the next row...
truncate_sheet : truncate (remove and recreate) [sheet_name]
before writing DataFrame to Excel file
to_excel_kwargs : arguments which will be passed to `DataFrame.to_excel()`
[can be dictionary]
Returns: None
"""
from openpyxl import load_workbook
import pandas as pd
# ignore [engine] parameter if it was passed
if 'engine' in to_excel_kwargs:
to_excel_kwargs.pop('engine')
writer = pd.ExcelWriter(filename, engine='openpyxl')
# Python 2.x: define [FileNotFoundError] exception if it doesn't exist
try:
FileNotFoundError
except NameError:
FileNotFoundError = IOError
try:
# try to open an existing workbook
writer.book = load_workbook(filename)
# get the last row in the existing Excel sheet
# if it was not specified explicitly
if startrow is None and sheet_name in writer.book.sheetnames:
startrow = writer.book[sheet_name].max_row
# truncate sheet
if truncate_sheet and sheet_name in writer.book.sheetnames:
# index of [sheet_name] sheet
idx = writer.book.sheetnames.index(sheet_name)
# remove [sheet_name]
writer.book.remove(writer.book.worksheets[idx])
# create an empty sheet [sheet_name] using old index
writer.book.create_sheet(sheet_name, idx)
# copy existing sheets
writer.sheets = {ws.title:ws for ws in writer.book.worksheets}
except FileNotFoundError:
# file does not exist yet, we will create it
pass
if startrow is None:
startrow = 0
# write out the new sheet
df.to_excel(writer, sheet_name, startrow=startrow, **to_excel_kwargs)
# save the workbook
writer.save()
re.sub(r"vasya", "", "Vasya foo vasya bar VASYA", 0, re.IGNORECASE)
https://ideone.com/cHZ8gO import random
class StopRecursion(Exception):
pass
def some_recursive_function(depth=0):
print ("depth=%d" % depth)
# играем в русскую рулетку
if random.randint(1,6) == 4:
raise StopRecursion
some_recursive_function(depth+1)
try:
some_recursive_function()
except StopRecursion:
print ("Recursion stopped")
>>> data = "ID: 001; Username: Ivan; Balance: 01.00; Status: active;"
>>> dict(x.split(":") for x in data.replace(" ","").split(";") if ":" in x)
{'ID': '001', 'Username': 'Ivan', 'Balance': '01.00', 'Status': 'active'}
>>> import re
>>> dict(re.findall("([^:]+):\s?([^;]+);\s?",data))
{'ID': '001', 'Username': 'Ivan', 'Balance': '01.00', 'Status': 'active'}
>>>
{
"response": {
"GeoObjectCollection": {
"metaDataProperty": {
"GeocoderResponseMetaData": {
"request": "Москва,Тверская 6",
"results": "10",
"found": "1"
}
},
"featureMember": [
{
"GeoObject": {
"metaDataProperty": {
"GeocoderMetaData": {
"precision": "exact",
"text": "Россия, Москва, Тверская улица, 6с1",
"kind": "house",
"Address": {
"country_code": "RU",
"formatted": "Россия, Москва, Тверская улица, 6с1",
"postal_code": "125009",
"Components": [
{
"kind": "country",
"name": "Россия"
},
{
"kind": "province",
"name": "Центральный федеральный округ"
},
{
"kind": "province",
"name": "Москва"
},
{
"kind": "locality",
"name": "Москва"
},
{
"kind": "street",
"name": "Тверская улица"
},
{
"kind": "house",
"name": "6с1"
}
]
},
"AddressDetails": {
"Country": {
"AddressLine": "Россия, Москва, Тверская улица, 6с1",
"CountryNameCode": "RU",
"CountryName": "Россия",
"AdministrativeArea": {
"AdministrativeAreaName": "Москва",
"Locality": {
"LocalityName": "Москва",
"Thoroughfare": {
"ThoroughfareName": "Тверская улица",
"Premise": {
"PremiseNumber": "6с1",
"PostalCode": {
"PostalCodeNumber": "125009"
}
}
}
}
}
}
}
}
},
"name": "Тверская улица, 6с1",
"description": "Москва, Россия",
"boundedBy": {
"Envelope": {
"lowerCorner": "37.607242 55.757926",
"upperCorner": "37.615452 55.762556"
}
},
"Point": {
"pos": "37.611347 55.760241"
}
}
}
]
}
}
}
{
"response": {
"GeoObjectCollection": {
"metaDataProperty": {
"GeocoderResponseMetaData": {
"request": "Киевская обл. , г. Киев, ул. Крещатик, дом 50, кв. 8",
"results": "10",
"found": "2"
}
},
"featureMember": [
{
"GeoObject": {
"metaDataProperty": {
"GeocoderMetaData": {
"precision": "exact",
"text": "Украина, Киев, улица Крещатик, 50",
"kind": "house",
"Address": {
"country_code": "UA",
"formatted": "Украина, Киев, улица Крещатик, 50",
"Components": [
{
"kind": "country",
"name": "Украина"
},
{
"kind": "province",
"name": "Киев"
},
{
"kind": "locality",
"name": "Киев"
},
{
"kind": "street",
"name": "улица Крещатик"
},
{
"kind": "house",
"name": "50"
}
]
},
"AddressDetails": {
"Country": {
"AddressLine": "Украина, Киев, улица Крещатик, 50",
"CountryNameCode": "UA",
"CountryName": "Украина",
"AdministrativeArea": {
"AdministrativeAreaName": "Киев",
"Locality": {
"LocalityName": "Киев",
"Thoroughfare": {
"ThoroughfareName": "улица Крещатик",
"Premise": {
"PremiseNumber": "50"
}
}
}
}
}
}
}
},
"name": "улица Крещатик, 50",
"description": "Киев, Украина",
"boundedBy": {
"Envelope": {
"lowerCorner": "30.516022 50.440632",
"upperCorner": "30.524232 50.445875"
}
},
"Point": {
"pos": "30.520127 50.443254"
}
}
},
{
"GeoObject": {
"metaDataProperty": {
"GeocoderMetaData": {
"precision": "other",
"text": "Украина, Киевская область",
"kind": "province",
"Address": {
"country_code": "UA",
"formatted": "Украина, Киевская область",
"Components": [
{
"kind": "country",
"name": "Украина"
},
{
"kind": "province",
"name": "Киевская область"
}
]
},
"AddressDetails": {
"Country": {
"AddressLine": "Украина, Киевская область",
"CountryNameCode": "UA",
"CountryName": "Украина",
"AdministrativeArea": {
"AdministrativeAreaName": "Киевская область"
}
}
}
}
},
"name": "Киевская область",
"description": "Украина",
"boundedBy": {
"Envelope": {
"lowerCorner": "29.266411 49.179114",
"upperCorner": "32.161466 51.554013"
}
},
"Point": {
"pos": "30.456149 50.29807"
}
}
}
]
}
}
}
sum(int(n[2:]) for n in arr)
.sum(int(re.sub(r'\D', '', n)) for n in arr)
. 1. Выгрузить подписчиков из похожих групп и пабликов и массово добавлять их в друзья с разных аккаунтов;
2. Отписываться от имени сообщества в комментариях очень крупных похожих групп и пабликов.
Какие способы ещё подскажете для продвижения именно политической группы?
TEXT_WORDS = []
index = 0
for word in TEXT.split():
index = TEXT.index(word, index)
TEXT_WORDS.append((word, index))
index += len(word)