"23432+22342+564"
^(\d+[+-]?)+[^+-]$
\d+ - только числа 1 или более
[+-]? - символ + или - 0 или 1 раз
(\d+[+-]?)+ повторить это все 1 или более раз
[^+-]$ - без символов +,- в конце строки
import re
while True:
s = input("str = ").replace(' ','')
if re.match(r'^(\d+[+-]?)+[^+-]$', s):
print("OK {}".format(s))
break
else:
print("Err {}".format(s))
for skipLink in skipList:
if tgLink[i] == skipLink:
if tgLink[i] in skipList:
if tgLink[i] not in skipList:
tgLink = [2, 5, 6]
skipList= [2]
for i in range(len(tgLink)):
if tgLink[i] not in skipList:
print(tgLink[i])
5
6
txt = 'sdf s7878 adsf '
trash_words = ['s7878']
s = ' '.join([i for i in txt.split() if i.isupper() or i.isdigit() or [x.isdigit() for x in i].count(True) > 0 or [x.isupper() for x in i].count(True) >= 2 and i.lower() not in trash_words])
print(s)
s7878
s = ' '.join([i for i in txt.split() if (i.isupper() or i.isdigit() or [x.isdigit() for x in i].count(True) > 0 or [x.isupper() for x in i].count(True) >= 2) and i.lower() not in trash_words])
def check_str(i):
if ((i.isupper() or
i.isdigit() or
[x.isdigit() for x in i].count(True) > 0 or
[x.isupper() for x in i].count(True) >= 2) and
i.lower() not in trash_words):
return True
return False
txt = 'sdf s7878 adsf '
trash_words = []
print(' '.join([i for i in txt.split() if check_str(i)]))
for index, i in enumerate(range(100), start=1):
print(i**index)
p = list()
for index, i in enumerate(range(100), start=1):
k = list()
for j in (str(i)):
k.append(int(j)**index)
p.append(k)
print(p)
p = list()
for i in range(100):
k = list()
for index, j in enumerate(str(i), start=1):
k.append(int(j) ** index)
p.append(k)
print(p)
soup = BeautifulSoup(file, 'html.parser')
blocks = soup.find_all('div', {'class': 'thumbnail offer'})
items = []
for block in blocks:
item = []
infos = block.h2.string.split(" ")
for info in infos:
if info and info != "vin:":
item.append(info)
for p in block.find_all('p'):
name, value = p.get_text().split(":")
item.append(value.strip())
items.append(item)
print(items)
[['Tesla', 'Model', 'Y', 'Long', 'Range', '2021', 'White', 'DUAL', '5YJYGDEE0MF160719', 'IAAI', '31992305', 'Stationary', 'Front End', '18388\xa0миль\xa0(Actual)', '09.02.2022'], ['Nissan', 'Leaf', 'S', '2013', 'Black', '80KW', '1N4AZ0CP9DC412799', 'IAAI', '32170717', 'Stationary', 'Mechanical', '0\xa0миль\xa0(Inoperable)', '08.02.2022'], ['Tesla', 'Model', 'S', '75D/100D/P100D', '2018', 'Black', 'U', '5YJSA1E2XJF281636', 'IAAI', '32362715', 'Stationary', 'Undercarriage', '48907\xa0миль\xa0(Actual)', '08.02.2022'], ['Tesla', 'Model', 'Y', 'Long', 'Range', '2021', 'Black', 'DUAL', '5YJYGAEE0MF293902', 'IAAI', '32286033', 'Stationary', 'Rear', '1364\xa0мили\xa0(Actual)', '08.02.2022'], ['Tesla', 'Model', '3', 'Range', 'Battery', '2018', 'Gray', 'MOTOR', '5YJ3E1EA1JF042556', 'IAAI', '32275149', 'Starts', 'Front End', '56236\xa0миль\xa0(Actual)', '08.02.2022'], ['Tesla', 'Model', '3', 'Range', 'Battery', '2018', 'White', 'MOTOR', '5YJ3E1EA7JF060592', 'IAAI', '32059234', 'Run and Drive', 'Rear', '43562\xa0мили\xa0(Actual)', '08.02.2022'], ['Mclaren', '570S', '2018', 'Yellow', '3.8L', 'SBM13FAA6JW005327', 'IAAI', '32102602', 'Run and Drive', 'Undercarriage', '19014\xa0миль\xa0(Actual)', '08.02.2022'], ['Ferrari', '458', 'Italia', 'Spider', '2015', 'Red', '4.5L', 'ZFF68NHA2F0209408', 'IAAI', '31755225', 'Stationary', 'Front End', '3270\xa0миль\xa0(Actual)', '08.02.2022'], ['Mclaren', '570S', '2018', 'Silver', '3.8L', 'SBM13FAA8JW005569', 'IAAI', '31615301', 'Stationary', 'Flood', '4677\xa0миль\xa0(Actual)', '08.02.2022'], ['Lamborghini', 'Huracan', '2017', 'Yellow', '5.2L', '10', 'ZHWUC2ZF7HLA05910', 'Copart', '66999041', 'Enhanced Vehicles', 'All Over', '0\xa0миль\xa0(Not Actual)', '07.02.2022'], ['Mclaren', 'Automotive', '600Lt', '2019', 'Orange', '3.8L', '8', 'SBM13RAAXKW007150', 'Copart', '65542851', 'Enhanced Vehicles', 'Top/Roof', '0\xa0миль\xa0(Not Actual)', '07.02.2022'], ['Ferrari', 'California', '2010', 'Red', '4.3L', 'ZFF65LJA5A0169518', 'IAAI', '32362410', 'Run and Drive', 'Right Rear', '49854\xa0мили\xa0(Actual)', '07.02.2022']]
def slugify(value, allow_unicode=False):
"""
Convert to ASCII if 'allow_unicode' is False. Convert spaces to hyphens.
Remove characters that aren't alphanumerics, underscores, or hyphens.
Convert to lowercase. Also strip leading and trailing whitespace.
"""
print(slugify(my_str).title())
soup = BeautifulSoup(file, 'html.parser')
blocks = soup.find_all('div', {'class': 'thumbnail offer'})
for block in blocks:
infos = block.h2.string.split(" ")
for info in infos:
if info and info != "vin:":
print(info)
for p in block.find_all('p'):
name, value = p.get_text().split(":")
print(value.strip())
Mclaren
Automotive
600Lt
2019
Orange
3.8L
8
SBM13RAAXKW007150
Copart
65542851
Enhanced Vehicles
Top/Roof
0 миль (Not Actual)
07.02.2022
sp = [ "0", "арбуз", "1", "тарелка", "2", "ложка", "2", "кружка", "0", "лопата"]
for i in range(len(sp)):
try:
sp[i] = str(int(sp[i])+1)
except:
pass
print(sp)
sp = [ "0", "арбуз", "1", "тарелка", "2", "ложка", "2", "кружка", "0", "лопата"]
for i in range(len(sp)):
if sp[i] == "0":
sp[i] = "1"
elif sp[i] == "1":
sp[i] = "2"
elif sp[i] == "2":
sp[i] = "3"
print(sp)