Category : output

I’ve got this piece of code dict1={‘h’:’H’, ‘e’:’E’, ‘l’:’LL’, ‘o’:’O’, ‘hello’:’HELLO’} def replfunc(match): return dict1[match.group(0)] regex = re.compile(‘|’.join(re.escape(x) for x in dict1)) with open(‘/old.txt’) as fin, open(‘/new.txt’,’w’, encoding=’UTF-8′) as fout: for line in fin: fout.write(regex.sub(replfunc,line)) This piece of code currently reads in the old text file and matches characters in this file with dict1 and ..

Read more

I want to buffer the output of my threads so that the output is generated in order. This is my code: from threading import Thread import time from random import randint def func_with_wait_time(wait_time): print(“First output in Function with wait time:”, wait_time) time.sleep(wait_time) print(“Last output in Function with wait time:”, wait_time) threads = [] for i ..

Read more

My Code: import random def random_phone_num_generator(): n = int(input("How many phonme numbers you want:n")) for i in range(0,n): first = str(random.randint(1, 888)).zfill(4) second = str(random.randint(1, 888)).zfill(3) last = (str(random.randint(1, 888)).zfill(3)) var1 = first+second+last var2 = "+44" phone_number = var2+var1 print(phone_number) random_phone_num_generator() I want to make a phone generater, and it works,but how can I write ..

Read more

I`m using Prophet (Time series library by Facebook) and it makes a lot of output. Something like this: Prophet output I`m already silent some output like this: @contextmanager def suppress_stdout(): with open(os.devnull, "w") as devnull: old_stdout = sys.stdout sys.stdout = devnull try: yield finally: sys.stdout = old_stdout But it doesn’t silent all types of output, ..

Read more