import os

class FileDownload:
def __init__(self):
self.exclude = ['db.sqlite3', 'logs', 'media', 'Pipfile', 'Pipfile.lock', 'Readme.md'] # 不需要打包的文件
self.file_list = [] def get_file(self, path): if os.path.isfile(path):
self.file_list.append(path) elif os.path.isdir(path):
for file in os.listdir(path): if file not in self.exclude and not file.startswith('__') and not file.startswith('.'):
new_dir = os.path.join(path, file)
if not os.path.isdir(new_dir):
self.file_list.append(new_dir)
else:
self.get_file(new_dir) if __name__ == '__main__':
filepath = r'C:\Users\zhang\PycharmProjects\server' # 项目所在目录
file_obj = FileDownload()
file_obj.get_file(filepath)
file_list = file_obj.file_list # 每一个文件的绝对路径
with open('code.txt', encoding='utf-8', mode='w+') as w: # 最终需要写入的文件:code.txt for file in file_list: # 循环文件列表,对文件进行读操作
with open(file, encoding='utf-8', mode='r') as f:
for line in f.readlines():
w.write(line)

ip转int与int转ip

将py文件打包到docx的更多相关文章

  1. python的py文件打包成exe

    一.首先需要安装Pyinstaller-- 使用pip来安装模块 (我电脑上装的是python的一个编译环境Anaconda,如果电脑上装的是python自带的IDE的话,就直接进入python的安装 ...

  2. 如何把py文件打包成exe可执行文件

    如何把py文件打包成exe可执行文件 1.安装 pip install pyinstaller 或者 pip install -i https://pypi.douban.com/simple pyi ...

  3. 如何将python3.6软件的py文件打包成exe程序

    在我们完成一个Python项目或一个程序时,希望将Python的py文件打包成在Windows系统下直接可以运行的exe程序.在浏览网上的资料来看,有利用pyinstaller和cx_Freeze进行 ...

  4. 将py文件打包为exe文件方法

    前提: pip是依赖python的,首先检查下windows机器上有没有安装python,或者有没有添加到环境变量中,如果都没有需要安装或者加入环境变量 安装pip 下载地址: https://pyp ...

  5. webService接口的py文件打包成exe

    (一)webService接口的py文件打包成exe,在python3.5版本.pyInstaller3.2版本.pywin32-219.win-amd64-py3.5版本打包时报错,原因可能是pyi ...

  6. 将py文件打包成exe文件

    PyInstaller工具是跨平台的,它既可以在 Windows平台上使用,也可以在 Mac OS X 平台上运行.在不同的平台上使用 PyInstaller 工具的方法是一样的,它们支持的选项也是一 ...

  7. 将做好的py文件打包成模块,供别人安装调用

    现在要将写完的3个py文件,打包. 步骤: 1.新建一个文件夹setup(名字随便取),在setup文件夹下,再新建一个文件夹financeapi. 2.将上面4个py文件拷贝至financeapi文 ...

  8. Python的.py文件打包成exe可执行文件

    前几天做了几个简单的爬虫python程序,于是就想做个窗口看看效果. 首先是,窗口的话,以前没怎么接触过,就先考虑用Qt制作简单的ui.这里用前面sinanews的爬虫脚本为例,制作一个获取当天sin ...

  9. python:win下将py文件打包成exe

    [环境]windows,正常运行的python文件 1.安装pyinstaller ,cmd下执行以下命令,需看到安装成功界面 pip install pyinstaller 2.cmd中进入要打包的 ...

随机推荐

  1. seekBar拖动滑块

    中秋节学习,, 通过拖动滑块,改变图片的透明度 <?xml version="1.0" encoding="utf-8"?> <LinearL ...

  2. 利用OpenGL固定流水线绘制球体

    在OS X上的一个OpenGL简单demo.所附赠的代码是绘制半个球体.开启了深度缓存和多重采样,采样数是4. 详细下载地址请见:http://www.cocoachina.com/bbs/read. ...

  3. Laya的动画制作,整图动画,序列图动画,时间轴动画,龙骨动画

    参考: Laya动画基础 Egret帧动画工具类 版本:2.1.1.1 序列图动画 白鹭的序列图动画,使用TexureMerger合图,然后使用MovieClip类播放. Laya的话,使用图集打包工 ...

  4. Linux下手动查杀木马

    (1).模拟木马程序病原体并让其自动运行 黑客让脚本自动执行的3种方法:1.计划任务:2.开机启动:3.系统命令被人替换,定一个触发事件. 1)生成木马程序病原体 [root@youxi1 ~]# v ...

  5. Silence Removal and End Point Detection JAVA Code(音频删除静音与结束判断)

    转载自:http://ganeshtiwaridotcomdotnp.blogspot.com/2011/08/silence-removal-and-end-point-detection_29.h ...

  6. LeetCode_263. Ugly Number

    263. Ugly Number Easy Write a program to check whether a given number is an ugly number. Ugly number ...

  7. C# 利用bat文件轻松创建windos 服务

    最近,一个项目需要一个后台服务,定时去读取数据,这是直接创建一个bat文件,双击执行就可以了,为了省事哦 主要分两个步奏 1.创建windows服务的应用程序.这一点不做过多讲解.网上有太多的例子 2 ...

  8. easyui datagrid里的toobar按钮隐藏、显示、禁用等方式的实现

    easyui datagrid里的toobar按钮隐藏.显示.禁用等方式的实现 //隐藏第一个按钮 $('div.datagrid-toolbar a').eq(0).hide(); //隐藏第一条分 ...

  9. 02点睛Spring MVC 4.1-@RequestMapping

    转发地址:https://www.iteye.com/blog/wiselyman-2213907 2.1 @RequestMapping @RequestMapping是SpringMVC的核心注解 ...

  10. virtualbox 安装扩展包 VirtualBox Extension Pack

    比如你下载的:Oracle_VM_VirtualBox_Extension_Pack-6.0.8.vbox-extpack ,双击安装没有反应. 可以在 VirtualBox 主菜单 管理-全局设定- ...