# -*- coding: utf-8 -*-
import pickle
class AAA(object):
def __init__(self, name):
self.name = name
a = AAA('original')
print(a, a.name)
with open('tst.pickle', 'wb') as f:
pickle.dump(a, f)
# -*- coding: utf-8 -*-
import pickle
class AAA(object):
def __init__(self, name):
self.name = name
with open('tst.pickle', 'rb') as f:
b = pickle.load(f)
print(b, b.name)
# -*- coding: utf-8 -*-
s = 'Ą᠄䄄㼄㸄㬄䰄㜄䌄㤄䈄㔀 㨄㸄㐀 㤀 㠀 ㌀㜀㐀 㐄㬄伀 㼄㸄㐄䈄㈄㔄䀄㘄㐄㔄㴄㠄伀 䄄㈄㸄㔄㌄㸀 〄㨄㨄〄䌄㴄䈄'
print(s.encode('utf-16be').decode('utf-16le'))
ЁИспользуйт5Рко4 908 374РдлOРподтверждениOРсвоег>Раккаунт
# -*- coding: utf-8 -*-
import numpy
a = numpy.array([[1, 3],
[1, 1],
[1, 5],
[1, 5],
[1, 5]])
b = numpy.insert(a, 1, numpy.array([1, 2]), 0)
print(b)
# -*- coding: utf-8 -*-
import urllib.request
resource = urllib.request.urlopen('http://dailybloggz.com/tfy/andreeva_secrets')
charset = resource.headers.get_content_charset()
print(charset)
content = resource.read().decode(charset)
print(content)
data=[4, 5, 7, 8, 9, 0, 3, 3, 6, 6]
c = [complex(a, b) for a, b in zip(data[:-1:2], data[1::2])]
print(c)
H:\My Documents\PyCharm>py
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
H:\My Documents\PyCharm>py -2
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:24:40) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
[global]
proxy = 127.0.0.1:3128
# -*- coding: utf-8 -*-
import numpy
import multiprocessing
def sub_sum(z):
return numpy.sum(z)
def parallel_sum(values, cpuz):
boundaries = [i for i in range(0, len(values), len(values)//cpuz)]
boundaries[-1] = len(values)
with multiprocessing.Pool(cpuz) as pool:
rc = pool.starmap(sub_sum, [(values[c1:c2],) for c1, c2 in zip(boundaries[: -1], boundaries[1:])])
return sum(rc)
if __name__ == '__main__':
cpuz = multiprocessing.cpu_count()
n = 999
values = numpy.array([i for i in range(n)])
print('cpuz =', cpuz)
print('sum =', parallel_sum(values, cpuz))
print('sum =', n*(n-1)//2)