import json
object = json.loads(str)
matrix = [
[11, 12, 13, 14],
[21, 22, 23, 24],
[31, 32, 33, 34],
[41, 42, 43, 44],
]
def walk(matrix):
zigzag = []
for index in range(1, len(matrix)):
slice = [i[:index] for i in matrix[:index]]
diag = [slice[i][len(slice)-i-1] for i in range(len(slice))]
if len(diag) % 2:
diag.reverse()
zigzag += diag
def geturl(href, baseurl):
domain = [i for i in baseurl.split('/') if i][1]
proto = [i for i in baseurl.split('/') if i][0]
protos = ['https://', 'http://', 'ftp://',]
for i in protos:
if href.startswith(i):
return href
if href.startswith('/'):
return proto + '://' + domain + href
if baseurl.endswith('/'):
return baseurl + href
return '/'.join(baseurl.split('/')[:-1]) + url
class ClientThread(threading.Thread):
def sendmsg(self, worker, msg):
worker.msg = msg
def processmsg(self, msg):
do_something(msg)
def run(self):
if name == "id5":
self.sendmsg(worker, msg)
worker = ClientThread(channel, details)
worker.start()
# Критерии
def isdigits(str):
for i in str:
if not i.isdigit()
return False
return True
def istext(str):
# какая-то логика
token = ("type_of_token", "value_of_token", len("value_of_token"))
def process_link(link):
tokenlist = []
for i in link.split('/'):
if isdigit(i):
tokenlist.append(("digit", i, len(i))
if istext():
tokenlist.append(("text", i, len(i))
return tokenlist