python - 如何删除备份文件,我不需要备份文件

标签 python

原始文件名为view.py、forms.py,但python自动添加/保存了一些名为view.pyc、forms.pyc的文件

我想删除那些多余的 view.pyc 和 forms.pyc 文件。

为什么我会得到那些 .pyc 文件?

或者我如何告诉 python 不要创建那些扩展名为 .pyc 的额外文件?

最佳答案

pyc文件是编译后的字节码文件,不是备份文件

  • 6.1.2“编译”Python 文件 http://docs.python.org/release/1.5.1p1/tut/node43.html

    As an important speed-up of the start-up time for short programs that use a lot of standard modules, if a file called "spam.pyc" exists in the directory where "spam.py" is found, this is assumed to contain an already-``byte-compiled'' version of the module spam. The modification time of the version of "spam.py" used to create "spam.pyc" is recorded in "spam.pyc", and the file is ignored if these don't match.

更新:

避免编写 pyc 文件(Python 2.6+)

  • 以 -B 标志开始(python -B)
  • 设置 PYTHONDONTWRITEBYTECODE 环境变量。

另见 How to avoid .pyc files?


Vim 备份命名为 view.py~

禁用 vim 备份使用

:se nobackup

关于python - 如何删除备份文件,我不需要备份文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8562144/

相关文章:

Python 字符串 'join' 比 '+' 更快(?),但这里有什么问题?

python - 通过 URL 发送列表

python - 使用 PyGObject 获取 GDBusMenuModel 的菜单项

具有基于键的默认值的Python dict

python - 在不使用模拟的情况下检查函数是否已在 Python unittest 中调用的规范方法是什么?

python - 如何限制 Python 中的并发线程数?

python - 如何使用 celery 选择 task_id?

python - 如何在 OpenCV2 python 中查看视频流

python - 不对整个终端使用 Npyscreen

python - 如何在 python 中更改现有第 3 方库中的函数