BOOKPYTHON Telegram 3472
Тесты могут требовать временные файлы или директории. Для этого отлично подойдет модуль tempfile.

Так как временные файлы обычно нужно удалять после использования, tempfile предоставляет как контекстный менеджер, так и простые функции:


import os
import tempfile

with tempfile.TemporaryDirectory() as dir_path:
open(os.path.join(dir_path, 'a'), 'w').close()
open(os.path.join(dir_path, 'b'), 'w').close()
open(os.path.join(dir_path, 'c'), 'w').close()

assert files_of(dir_path) == ['a', 'b', 'c']


👉@BookPython
👍51



tgoop.com/BookPython/3472
Create:
Last Update:

Тесты могут требовать временные файлы или директории. Для этого отлично подойдет модуль tempfile.

Так как временные файлы обычно нужно удалять после использования, tempfile предоставляет как контекстный менеджер, так и простые функции:


import os
import tempfile

with tempfile.TemporaryDirectory() as dir_path:
open(os.path.join(dir_path, 'a'), 'w').close()
open(os.path.join(dir_path, 'b'), 'w').close()
open(os.path.join(dir_path, 'c'), 'w').close()

assert files_of(dir_path) == ['a', 'b', 'c']


👉@BookPython

BY Библиотека Python разработчика | Книги по питону


Share with your friend now:
tgoop.com/BookPython/3472

View MORE
Open in Telegram


Telegram News

Date: |

While the character limit is 255, try to fit into 200 characters. This way, users will be able to take in your text fast and efficiently. Reveal the essence of your channel and provide contact information. For example, you can add a bot name, link to your pricing plans, etc. Invite up to 200 users from your contacts to join your channel Your posting frequency depends on the topic of your channel. If you have a news channel, it’s OK to publish new content every day (or even every hour). For other industries, stick with 2-3 large posts a week. Each account can create up to 10 public channels The best encrypted messaging apps
from us


Telegram Библиотека Python разработчика | Книги по питону
FROM American