How to create an empty file in python

Method 1 open:

import os

file_name = "123.txt"
open(file_name, "w")

Method 2 pathlib:

import pathlib

file_name = "123.txt"
pathlib.Path(file_name).touch()

 

 

Guess you like

Origin blog.csdn.net/whatday/article/details/113783540