Форум сайта python.su
date = column_property(func.unnest(func.get_occurrences(cast(rrule, RRule), cast(func.now(), TIMESTAMP))).label("date"))
>>> Event.query.count() 182 >>> len(Event.query.all()) 1
def distance(a, b):
"Calculates the Levenshtein distance between a and b."
n, m = len(a), len(b)
if n > m:
# Make sure n <= m, to use O(min(n,m)) space
a, b = b, a
n, m = m, n
current_row = range(n+1) # Keep current and previous row, not entire matrix
for i in range(1, m+1):
previous_row, current_row = current_row, [i]+[0]*n
for j in range(1,n+1):
add = previous_row[j]+ 3
if a[j-1] != b[i-1]:
change += 1
delete = current_row[j-1]+2
if a[j-1] != b[i-1]:
change += 1
change = previous_row[j-1] + 1
if a[j-1] != b[i-1]:
change += 1
current_row[j] = min(add, delete, change)
return current_row[n]
# coding=utf-8 from selenium import webdriver from xml.dom import minidom import re, time, sys options = webdriver.ChromeOptions() options.add_argument('--user-data-dir=C:/Users/Shadow/AppData/Local/Google/Chrome/User Data') driver = webdriver.Chrome(chrome_options = options) def subscription(id): #Открываем URL канала url = u'https://www.youtube.com/channel/' + id[0] driver.get(url) #Находим кнопку подписки button = driver.find_element_by_xpath('//*[@id="c4-primary-header-contents"]/div/span/button[1]') #Если на кнопке нет атрибута 'data-is-subscribed="true"' - значит подписка не оформлена if button.get_attribute('data-is-subscribed') == None: #то кликаем на кнопку button.click() #Засыпаем на три секунды что-бы клик успел отработать, необходим при медленном интернете time.sleep(3) sys.stdout.write(" +++\r\n") else: #Иначе пишем: sys.stdout.write(" ---\r\n") ### Парсим XML файл подписок subscription_manager.xml берем здесь https://www.youtube.com/subscription_manager ### в самом низу страницы, есть кнопка "Экспортировать подписки", кладем его рядом с этим скриптом xmldoc = minidom.parse('subscription_manager.xml') itemlist = xmldoc.getElementsByTagName('outline') #Печатаем количество подписок print(len(itemlist)) #Цикл обработки XML документа for s in itemlist: try: feed_url = s.attributes['xmlUrl'].value #Находим ID канала регулярным выражением p = re.compile('channel_id=(.*)$') m = p.findall(feed_url) #Печатаем название канала sys.stdout.write(s.attributes['title'].value) #Вызываем функцию подписки subscription(m) except: pass
cv.NamedWindow("camera", 1) capture = cv.CaptureFromCAM(0) while True: img = cv.QueryFrame(capture) cv.ShowImage("camera", img) if cv.WaitKey(10) == 27: break cv.DestroyWindow("camera")
6/20/16 18:12:51.778 NL: File “/Users/kobzar/Develop/Python/RN/dist/NL.app/Contents/Resources/__boot__.py”, line 351, in <module>
6/20/16 18:12:51.778 NL: _run()
6/20/16 18:12:51.778 NL: File “/Users/kobzar/Develop/Python/RN/dist/NL.app/Contents/Resources/__boot__.py”, line 336, in _run
6/20/16 18:12:51.778 NL: exec(compile(source, path, ‘exec’), globals(), globals())
6/20/16 18:12:51.778 NL: File “/Users/kobzar/Develop/Python/RN/dist/NL.app/Contents/Resources/NL.py”, line 5, in <module>
6/20/16 18:12:51.778 NL: import rumps
6/20/16 18:12:51.778 NL: File “/Users/kobzar/Develop/Python/RN/dist/NL.app/Contents/Resources/lib/python2.7/rumps/__init__.py”, line 25, in <module>
6/20/16 18:12:51.778 NL: from .rumps import (separator, debug_mode, alert, notification, application_support, timers, quit_application, timer,
6/20/16 18:12:51.778 NL: File “/Users/kobzar/Develop/Python/RN/dist/NL.app/Contents/Resources/lib/python2.7/rumps/rumps.py”, line 15, in <module>
6/20/16 18:12:51.778 NL: from Foundation import (NSDate, NSTimer, NSRunLoop, NSDefaultRunLoopMode, NSSearchPathForDirectoriesInDomains,
6/20/16 18:12:51.778 NL: File “Foundation/__init__.pyc”, line 8, in <module>
6/20/16 18:12:51.779 NL: File “objc/__init__.pyc”, line 18, in <module>
6/20/16 18:12:51.779 NL: File “objc/__init__.pyc”, line 15, in _update
6/20/16 18:12:51.779 NL: AttributeError: ‘module’ object has no attribute ‘_objc’
6/20/16 18:12:51.851 NL: NL Error
import cv2 backsub = cv2.BackgroundSubtractorMOG() #вычитаем фон capture = cv2.VideoCapture("/car.avi") #грузим видео i = 0 minArea=1 while True: ret, frame = capture.read() fgmask = backsub.apply(frame, None, 0.01) erode=cv2.erode(fgmask,None,iterations=3) moments=cv2.moments(erode,True) area=moments['m00'] if moments['m00'] >=minArea: x=int(moments['m10']/moments['m00']) y=int (moments['m01']/moments['m00']) if y>100: i=i+1 print(i) #print(x,y) cv2.putText(frame,'COUNT: %r' %i, (10,30), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 0, 0), 2) cv2.imshow("Track", frame) cv2.imshow("background sub", fgmask) key = cv2.waitKey(100) if key == ord('q'): break
def uploadphoto(c,photo): files = {'profile_pic': (photo, open('avatars/'+photo, 'rb'), 'image/jpeg')} return requests.post('https://www.instagram.com/accounts/web_change_profile_picture/', headers={'referer': 'https://www.instagram.com/', 'origin': 'https://www.instagram.com/', 'x-csrftoken': c.cookies['csrftoken'], 'x-instagram-ajax': '1', 'x-requested-with': 'XMLHttpRequest'}, cookies=c.cookies, files=files)
C:\Users\User\Projects\I>python setup.py py2exe Traceback (most recent call last): File "<frozen importlib._bootstrap>", line 1519, in _find_and_load_unlocked AttributeError: 'module' object has no attribute '__path__' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "setup.py", line 1, in <module> from distutils.core import setup File "C:\Users\User\Projects\I\distutils.py", line 1, in <module> from distutils.core import setup ImportError: No module named 'distutils.core'; distutils is not a package
from distutils.core import setup import py2exe setup( windows=[{"script":"gui.py"}], options={"py2exe": {"includes":["sip", "random", "json", "os", "multiprocessing.dummy", "requests", "tkinter"]}} )