nc -l 4545
, с другого подключитесь к нему:nc $remote_ip 4545
, где $remote_ip - это ip-адрес сервера. Дальше можете набирать текст на любой из сторон, он будет передан на другой компьютер.l = list(range(10**5))
for i in l: # 107 ms
print(i, end=' ')
s = ' '.join(map(str, l))
print(s) # 55 ms
for i in range(n):
left = 1
right = l
...
elif x[m[mid]] == x[i]:
left += 1
...
for i in range(n):
left = 1
right = l
while left <= right:
mid = (left+right) // 2
if x[m[mid]] <= x[i]:
left = mid+1
else:
right = mid-1
...
def compute_digits_sum(number):
digits_sum = 0
while number:
digits_sum += number % 10
number = number // 10
return digits_sum
def compute_progression_digits_sum(number):
return sum(compute_digits_sum(i) for i in range(number + 1))
def set(self):
"""Set the internal flag to true. All coroutines waiting for it to
become true are awakened. Coroutine that call wait() once the flag is
true will not block at all.
"""
if not self._value:
self._value = True
for fut in self._waiters:
if not fut.done():
fut.set_result(True)
@coroutine
def wait(self):
"""Block until the internal flag is true.
If the internal flag is true on entry, return True
immediately. Otherwise, block until another coroutine calls
set() to set the flag to true, then return True.
"""
if self._value:
return True
fut = self._loop.create_future()
self._waiters.append(fut)
try:
yield from fut
return True
finally:
self._waiters.remove(fut)
In [4]: '1'.rjust(10, '0')
Out[4]: '0000000001'
In [5]: t1 = (2017, 10, 28)
In [6]: t2 = (2018, 10, 28)
In [7]: t1 < t2
Out[7]: True
def main():
popenList = {}
CLI_MENU.hello_banner()
while True:
command = input("CLI>: ")
command = CLI_MENU.analyze_command(command)
if command[0] == "add":
if len(command) > 1:
if CLI_MENU.is_ip_address(command[1]):
CLI_MENU.add_ip_to_monitoring(ip=command[1],popenlist=popenList)
else:
print("You should put ip address after word add.")
print("Print help and press Enter for more information.\n")
elif command[0] == "del":
if len(command) > 1:
CLI_MENU.stop_popen(ip=command[1], popenlist=popenList)
else:
print("You should put ip address after word del.")
print("Print help and press Enter for more information.\n")
elif command[0] == "import" and len(command) < 2:
ipexportlist = CLI_MENU.import_ip_from_file()
if len(ipexportlist) > 0 and (ipexportlist != "FileError"):
for ip in ipexportlist:
if CLI_MENU.is_ip_address(ip):
CLI_MENU.add_ip_to_monitoring(ip,popenList)
else: print(f"{ip} is not a correct ip, it will not be added to monitoring.")
elif ipexportlist == "FileError":
pass
else: print("File IPLIST.txt contains no IPs, nothing will be added to monitoring.")
elif command[0] == "show": CLI_MENU.show_ip_in_monitoring(popenlist=popenList)
elif command[0] == "help": CLI_MENU.give_help_menu()
elif command[0] == "exit": CLI_MENU.exit_program(popenlist=popenList)
elif command[0] == "FreeSpace": print()
else: print("Incorrect command, Please try again.\n")