About 460,000 results
Open links in new tab
  1. How to create a new text file using Python - Stack Overflow

    Jun 16, 2024 · The default value is r and will fail if the file does not exist 'r' open for reading (default) 'w' open for writing, truncating the file first Other interesting options are 'x' open for …

  2. python - Create a file if it doesn't exist - Stack Overflow

    Mar 5, 2016 · First let me mention that you probably don't want to create a file object that eventually can be opened for reading OR writing, depending on a non-reproducible condition.

  3. python - How do I write JSON data to a file? - Stack Overflow

    To get utf8-encoded file as opposed to ascii-encoded in the accepted answer for Python 2 use:. import io, json with io.open('data.txt', 'w', encoding='utf-8') as f: f.write(json.dumps(data, …

  4. Creating a BAT file for python script - Stack Overflow

    Apr 15, 2019 · @echo off title Execute Python [NarendraDwivedi.Org] :main echo. set/p filename=File Name : echo. %filename% goto main Now place this file in the folder where …

  5. python - Automatically create file 'requirements.txt' - Stack Overflow

    Mar 19, 2019 · Firstly, your project file must be a py file which is direct python file. If your file is in ipynb format, you can convert it to py type by using the line of code below: jupyter nbconvert - …

  6. python - How do I copy a file? - Stack Overflow

    Sep 23, 2008 · shutil has many methods you can use. One of which is: import shutil shutil.copyfile(src, dst) # 2nd option shutil.copy(src, dst) # dst can be a folder; use …

  7. Create empty file using python - Stack Overflow

    There is no way to create a file without opening it There is os.mknod("newfile.txt") (but it requires root privileges on OSX). The system call to create a file is actually open() with the O_CREAT …

  8. python - How do I create a file at a specific path? - Stack Overflow

    Feb 24, 2011 · The file is created wherever the root of the python interpreter was started. Eg, you start python in /home/user/program , then the file "test.py" would be located at …

  9. How can I make an EXE file from a Python program?

    Sep 8, 2008 · How I Distribute Python applications on Windows - py2exe & InnoSetup. From the site: There are many deployment options for Python code. I'll share what has worked well for …

  10. python - How can I manually generate a .pyc file from a .py file ...

    Jul 31, 2016 · create a new python file in the directory of the file. type import (the name of the file without the extension) run the file; open the directory, then find the pycache folder; inside …

Refresh