# import needed modules
import android
import time
import sys, select, os #for loop exit
#Initiate android-module
droid = android.Android()
#notify me
droid.makeToast("fetching GPS data")
print("start gps-sensor...")
droid.startLocating()
while True:
#exit loop hook
if sys.stdin in select.select([sys.stdin], [], [], 0)[0]:
line = input()
print("exit endless loop...")
break
#wait for location-event
event = droid.eventWaitFor('location',10000).result
if event['name'] == "location":
try:
#try to get gps location data
timestamp = repr(event['data']['gps']['time'])
longitude = repr(event['data']['gps']['longitude'])
latitude = repr(event['data']['gps']['latitude'])
altitude = repr(event['data']['gps']['altitude'])
speed = repr(event['data']['gps']['speed'])
accuracy = repr(event['data']['gps']['accuracy'])
loctype = "gps"
except KeyError:
#if no gps data, get the network location instead (inaccurate)
timestamp = repr(event['data']['network']['time'])
longitude = repr(event['data']['network']['longitude'])
latitude = repr(event['data']['network']['latitude'])
altitude = repr(event['data']['network']['altitude'])
speed = repr(event['data']['network']['speed'])
accuracy = repr(event['data']['network']['accuracy'])
loctype = "net"
data = loctype + ";" + timestamp + ";" + longitude + ";" + latitude + ";" + altitude + ";" + speed + ";" + accuracy
print(data) #logging
time.sleep(5) #wait for 5 seconds
print("stop gps-sensor...")
droid.stopLocating()
from tkinter import *
c = Canvas(width=160, height=100, bg='grey80')
c.pack()
oval = c.create_oval(30, 10, 130, 80, fill="orange")
def oval_func(event):
print("Зачем ты нажал на этот овал?")
def oval_func1(event):
print("Навел мышью да?")
c.tag_bind(oval, '<Button-1>', oval_func)
c.tag_bind(oval, '<Motion>', oval_func1)
>>> import re
>>> from urllib.request import urlopen
>>> regex = r"createObject\(\"Placemark\",\s?new\sYMaps\.GeoPoint\(([\d\s\.\,]+)\),\s?\"(\w+)\",\s?'([^']+)'\s?\);"
>>> text = str(urlopen("https://koleso.ru/shops/").read(),"windows-1251")
>>> result = [list(x.groups()) for x in re.finditer(regex, text, re.MULTILINE)]
>>> result[0]
['37.834803,55.776082', 'Koleso', '<div><a class="MenuNav_YmapsBalloonPreButton" style="font-size:11px;" href="/shops/3653118/">Карточка магазина</a></div><div class="MenuNav_YmapsBalloonComment"><b>г. Москва</b><br />ш. Энтузиастов, д. 63<br />тел.: +7(499)308-59-93</div>']
>>>
import wx
i=0
def Timer1(evt):
global text1,i
i+=1
text1.SetLabelText(str(i))
app = wx.App()
frame = wx.Frame(None, -1, 'win.py')
t1 = wx.Timer(frame)
t1.Start(1000)
panel = wx.Panel(frame, wx.ID_ANY)
text1 = wx.StaticText(panel, wx.ID_ANY, str(i), (50, 10))
frame.Bind(wx.EVT_TIMER, Timer1)
frame.Show()
frame.Centre()
app.MainLoop()
@app.route('/<str:name>.html')
def Loader(name):
if os.path.isfile(name+".txt"):
text = open(name+".txt","rb").read()
else:
text = "не найдено"
return render_template('ch.html', text=text)
<pre>{{ text }}</pre>
a,b,c,d = int(a),int(b),int(c),int(d) #на всякий случай сделаем натуральными
if 1<=a<=b and a<=b<=10 and 1<=c<=d and c<=d<=10:
pass
if a in range(1, int(b+1)) and b in range(int(a), 11) and c in range(1, int(d+1)) and d in range(int(с), 11):
pass