[12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
os.system("tar cvf backup/backup_month/%d.tar.gz * && rm backup/*" % ((datetime.date.today().month - 2) % 12 + 1))
import re
with open("блаблабла.txt", "rb") as f:
s = re.sub(r'\s+', ' ', f.read().decode('WINDOWS-1251'), flags=re.M)
for s in re.split(r'(?<=[.!?…]) ', s):
print(s)
array1 = [1, 2, 3]
array2 = []
array3 = [1, 3]
if not all((array1, array2, array3)):
print("есть пустой!")
myArray1 = [1, 2, 3]
myArray2 = [2, 3]
myArray3 = [1, 3]
print([l for l in (myArray1, myArray2, myArray3) if l])
# или
print([','.join(map(str, l)) for l in (myArray1, myArray2, myArray3) if l] or 'pustoi')
dot=range(dots)
[0, 1, 2... dots-1]
dot = [] # вот пустой лист
for i in range(dots):
# добавляю в него листы вида [x, y]
dot.append([random.randrange(0, dots), random.randrange(0, dots)])
вот в этой строке pos = lines[i][1]
lines имеет значение ['あちら', '(n) (1) there', 'yonder', 'that']
for i in range(10):
a = i // 2
b = i % 2
print(i, a, b, a * 2 + b )
from random import choice
import re
def main(s):
for g in re.finditer(r'-?\d+', s):
i = int(g.group(0))
# print(i)
nums = [str(i) for i in range(-100, 101)]
N = 10 ** 6
s = ' '.join(choice(nums) for _ in range(N))
main(s)
def main(s):
d = {str(i): i for i in range(-100, 101)}
for g in re.finditer(r'-?\d+', s):
i = d[g.group(0)]