Category : file

I have a next code and next files: import re with open("forbidden_words.txt", "r", encoding="utf-8") as stop, open(f'{input()}’, ‘r’, encoding=’utf-8′) as file: stop_words = stop.readline().split(" ") text_file = file.readline() for i in stop_words: text_file = re.sub(i, ‘*’*len(i), text_file, flags=re.IGNORECASE) print(text_file) forbidden_words.txt: warning priority candidate leadership recording judgment law responsibility efficiency advertising imagination department maintenance poet village ..

Read more

I am using backblaze and b2sdk.v2 in Flask to upload file This is code I tried # I am not showing authorization code… def upload_file(file): bucket = b2_api.get_bucket_by_name(bucket_name) file = request.files[‘file’] bucket.upload( upload_source=file, file_name=file.filename, ) This show error like this AttributeError: ‘SpooledTemporaryFile’ object has no attribute ‘get_content_length’ I think it’s because I am using Filestorage ..

Read more

I can’t use the –noconsole or –windowed flags with pyinstaller (which I need) because they render the executable useless. Compiling the executable with either of those flags results in an executable that throws an OSError: [Errno 30] Read-only file system: my_file.txt when I try to open my_file.txt in append mode (which is necessary for my ..

Read more

Python provides the open() function, which can open a file if its name was specified. But is there a way to open an already existing file? Consider the following situation: with open(‘plain.txt’, mode=’w’) as file: file.write(‘a_linen’) open(file, mode=’r’) But it throws an error: TypeError: expected str, bytes or os.PathLike object, not TextIOWrapper Source: Python-3x..

Read more

Python provides the open() function, which can open a file if its name was specified. But is there a way to open an already existing file? Consider the following situation: with open(‘plain.txt’, mode=’w’) as file: file.write(‘a_linen’) open(file, mode=’r’) But it throws an error: TypeError: expected str, bytes or os.PathLike object, not TextIOWrapper Source: Python-3x..

Read more