Python
python学习
小金~~
马上去学习
展开
-
python将自己的程序使用pyinstall打包(打包多个.py文件)
目录参考链接0. 安装pyinstaller,[github地址](https://github.com/pyinstaller/pyinstaller) ,[website](https://pyinstaller.readthedocs.io/en/latest/)1. 项目的目录形式2. 在项目目录下执行命令 `pyi-makespec setup.py` (setup.py是程序的主入口文件)3. 修改.spec文件4. 执行.spec文件,生成exe,输入命令: `pyinstaller -D s原创 2021-11-03 11:01:22 · 840 阅读 · 0 评论 -
python random.sample
random.sample 从集合或者序列中,无放回采样用法:sample_list=random.sample(population, k)# population : 可以是一个集合,也可以是序列(list,tuple,或者字符串)# k : 0<= k<= len(population) # 返回一个list,如果是字符串的话,返回的是['index1','index2']随机选择的索引值# 注意:不会改变原来的 population测试:import randomr原创 2021-10-28 10:34:12 · 3869 阅读 · 0 评论 -
python read()、readline()和readlines()之前的区别
read()、readline()和readlines()之前的区别read() 读取的是全部内容,返回一个字符串str,len(str)包含换行符,空格with open(TXT_PATH, 'r', encoding="utf-8") as file: print('read():') all=file.read() print(type(all),len(all),all)打印结果:read():<class ‘str’> 85 L45110L原创 2021-06-29 10:55:55 · 80 阅读 · 0 评论 -
python excel读取、修改
1. 读取数据sheets=['第一批','第二批','第三批']count=0for sh in sheets: print('当前sheet:',sh) # DataFrame数据,可以转为numpy data = pd.read_excel(excel_path,sheet_name=sh) # 不指定sheet_name默认只读第一个sheet print(data.shape) #不含表头,data数据也不含表头 row, col = data.shape[0], dat原创 2021-06-21 17:29:36 · 1813 阅读 · 0 评论 -
Python 命令行参数
Python代码学习Python部分argparse、optparse、getopt ——解析Python传入的参数 三者都是pyrhon的内建模块,用来处理命令行参数。getopt只能简单处理 命令行参数;optparse功能强大,而且易于使用,可以方便地生成标准的、符合Unix/Posix 规范的命令行说明(但目前已被弃用);argparse 模块是基于 optparse 的,使用方法相似,从 sys.argv 中解析参数,可编写用户友好的命令行界面,自动生成帮助和使用信息,对于无效参数可产生原创 2021-05-19 16:23:53 · 178 阅读 · 2 评论 -
Python 输入多行,读取txt文件
1. 使用inputinput a: 2323 <class 'str'>2.使用sys.stdim.readine() import sys c = sys.stdin.readline() #单行文本,回车结束 #sys.stdin.readline().strip('\n') 去掉换行符 print(c, type(c))232343...原创 2020-02-25 19:56:50 · 804 阅读 · 0 评论 -
Python库之Numpy(一)
介绍NumPy模块是Python的一种开源的数值计算扩展,是一个用python实现的科学计算包,主要包括:nddary:具有矢量算术运算和复杂广播能力的多维数组ufunc: 对整组数据快速运算的标准数学函数随机生成函数,傅里叶变换,线性代数操作nddary—Numpy的核心数据结构与标准Python库类是有差别的,array.array只处理一维数组,提供的功能也很少。num...原创 2018-11-27 20:34:49 · 717 阅读 · 0 评论 -
os模块中关于文件/目录常用的函数使用方法
os模块中关于文件/目录常用的函数使用方法翻译 2018-11-26 11:23:25 · 241 阅读 · 0 评论 -
字符串格式化符号含义及转义字符含义
原创 2018-11-06 21:39:16 · 211 阅读 · 0 评论 -
字符串的方法及注释
原创 2018-11-06 20:34:45 · 149 阅读 · 0 评论