随笔分类 -  python

python笔记,欢迎评论交流
python 基础操作 plus
摘要:将python列表中的多个列表转化为一个列表:列表的扁平化处理总结 方法一: 使用 itertools # 速度最快 import itertools a = [[1, 2, 3, 4], [4, 4, 5, 6], [7], [7, 8, 9]] out = list(itertools.chai 阅读全文

posted @ 2022-11-16 15:18 闹不机米 阅读(43) 评论(0) 推荐(0) 编辑

python 查找多边形上最近点的坐标
摘要:from shapely.geometry import Polygon, Point, LinearRing poly = Polygon([(0, 0), (2, 8), (14, 10), (6, 1)]) point = Point(12, 4) pol_ext = LinearRing(p 阅读全文

posted @ 2022-03-07 10:56 闹不机米 阅读(456) 评论(0) 推荐(1) 编辑

Cartopy 安装
摘要:使用说明,如何画图 import cartopy.crs as ccrs import matplotlib.pyplot as plt from cnmaps import get_adm_maps, draw_map jingjinji = get_adm_maps('北京市') + get_a 阅读全文

posted @ 2022-01-24 15:24 闹不机米 阅读(2112) 评论(0) 推荐(0) 编辑

python 如何读取GFS数据
摘要:安装xarray包: conda install -c conda-forge xarray 安装解码库"eccodes": conda install -c conda-forge eccodes 安装cfgrib 库: conda install -c conda-forge cfgrib im 阅读全文

posted @ 2021-12-30 20:31 闹不机米 阅读(273) 评论(0) 推荐(0) 编辑

python 安装eccodes后报错 该怎么处理?
摘要:conda install eccodes -c conda-forge 成功安装eccodes 2.23.0 ,但是导入时报错No module named 'eccodes' 解决方式为继续安装python-eccodes conda install python-eccodes -c cond 阅读全文

posted @ 2021-12-30 20:29 闹不机米 阅读(654) 评论(0) 推荐(0) 编辑

pip 命令参数说明
摘要:从本地目录文件安装(禁用联网检查PyPI) pip install --no-index --find-links=c:\xxx\xxx 或者.(相对当前目录) xxx.whl 或者 xxx.tar.gz 详细参考官方说明 https://packaging.python.org/tutorials 阅读全文

posted @ 2021-11-30 17:05 闹不机米 阅读(517) 评论(0) 推荐(0) 编辑

pyinstaller 打包成 exe
摘要:通用参数 参数名描述说明 -h 显示帮助 无 -v 显示版本号 无 –distpath 生成文件放在哪里 默认:当前目录的dist文件夹内 –workpath 生成过程中的中间文件放在哪里 默认:当前目录的build文件夹内 -y 如果dist文件夹内已经存在生成文件,则不询问用户,直接覆盖 默认: 阅读全文

posted @ 2021-11-29 20:22 闹不机米 阅读(377) 评论(0) 推荐(0) 编辑

python ftplib模块使用
摘要:Python中默认安装的ftplib模块定义了FTP类,可用来实现简单的ftp客户端,用于上传或下载文件。 ftp登陆连接 from ftplib import FTP #加载ftp模块 ftp=FTP() #设置变量 ftp.set_debuglevel(2) #打开调试级别2,显示详细信息 ft 阅读全文

posted @ 2021-10-21 09:55 闹不机米 阅读(255) 评论(0) 推荐(0) 编辑

Win10 安装GNU 编译器(gcc、g++ 和 gfortran)
摘要:安装地址 https://www.scivision.dev/windows-gcc-gfortran-cmake-make-install/ 注意添加环境变量。。。 阅读全文

posted @ 2021-06-22 20:23 闹不机米 阅读(982) 评论(0) 推荐(0) 编辑

Object of type ndarray is not JSON serializable
摘要:class NpEncoder(json.JSONEncoder): def default(self, obj): if isinstance(obj, np.integer): return int(obj) elif isinstance(obj, np.floating): return f 阅读全文

posted @ 2021-06-07 09:54 闹不机米 阅读(625) 评论(0) 推荐(0) 编辑

swig 打包成 python包
摘要:安装 win: http://www.swig.org/download.html 将解压目录,将swig.exe配置到PATH环境变量中 在cmd中测试输入swig,出现‘Must specify an input file. Use -help for available options.’表示 阅读全文

posted @ 2021-04-22 10:53 闹不机米 阅读(247) 评论(0) 推荐(0) 编辑

python 正则断言
摘要:前项肯定 ?<= 前面必须是“abc”才能匹配后面写的内容 import re re.search(r”(?<=abc)\d+”,”abc123deb”).group() 后项肯定 ?= 后面必须是“abc”才能匹配前面写的内容 import re re.search(r”(\d+(?=abc))” 阅读全文

posted @ 2021-03-30 17:22 闹不机米 阅读(207) 评论(0) 推荐(0) 编辑

sitecustomize.py 用法,在python启动时会自动执行其中的语句
摘要:在python安装目录下的lib下的site-packages 目录中,新建文件sitecustomize.py。这是个特殊的文件,在python启动时会自动执行其中的语句。在sitecustomize.py中的语句 sys.setdefaultencoding("UTF-8") 的作用是将默认编码 阅读全文

posted @ 2021-03-18 09:20 闹不机米 阅读(391) 评论(0) 推荐(0) 编辑

ERROR 1: PROJ: pj_obj_create: Open of /opt/conda/share/proj failed
摘要:import os os.environ['PROJ_LIB'] = '/opt/conda/share/proj' 必须得指定到要使用的虚拟环境路径下 如:我的使用的虚拟环境名字 env_python 和对应路径 os.environ['PROJ_LIB'] = '/opt/conda/envs/ 阅读全文

posted @ 2021-03-18 09:15 闹不机米 阅读(1054) 评论(1) 推荐(0) 编辑

Warning 1: Recode from CP437 to UTF-8 failed with the error: "Invalid argument".
摘要:# CPL_ZIP_ENCODING if 'CPL_ZIP_ENCODING' not in os.environ: # Prevents "Warning 1: Recode from CP437 to UTF-8 failed with the error: "Invalid argument 阅读全文

posted @ 2021-03-18 09:13 闹不机米 阅读(391) 评论(0) 推荐(0) 编辑

python 找不到工作目录,指定工作路径
摘要:import sys sys.path.insert(0,"/app/download/download_shaobing") 阅读全文

posted @ 2021-03-08 11:23 闹不机米 阅读(259) 评论(0) 推荐(0) 编辑

python 获取每月的天数
摘要:import calendar monthRange = calendar.monthrange(2020, 12) print(monthRange) #>>> (1, 31) # 输出的是一个元组,第一个元素是所查月份的第一天对应的是星期几(0-6),第二个元素是这个月的天数。 # 以上实例输出 阅读全文

posted @ 2020-12-24 11:38 闹不机米 阅读(3201) 评论(0) 推荐(0) 编辑

MongoDB 学习笔记
摘要:MongoDB简介 MongoDB是一个基于 分布式文件存储 的数据库。由 C++ 语言编写。旨在为WEB应用提供可扩展的高性能数据存储解决方案。 MongoDB是一个介于 关系数据库 和非关系数据库之间的产品,是非关系数据库当中功能最丰富,最像关系数据库的。它支持的数据结构非常松散,是类似 jso 阅读全文

posted @ 2020-12-18 17:16 闹不机米 阅读(139) 评论(0) 推荐(0) 编辑

Windows10 安装 Mongodb
摘要:下载 官网下载地址 https://www.mongodb.com/try?jmp=nav#community 选择custom安装方式,手动切换安装目录,如:安装在 D:\MongoDB(不要安装在默认位置,系统盘保护,好多操作很难受) 配置环境变量 安装成功之后,将 mongodb 目录下的 b 阅读全文

posted @ 2020-12-17 16:09 闹不机米 阅读(136) 评论(0) 推荐(0) 编辑

bz2 解压文件
摘要:解压文件,写入另一个文件中 pp = r'C:\Users\xixi\Desktop\ecmf\W_NAFP_C_ECMF_20200101054247_P_C1D01010000010100001.bz2' with open('xxxxxx.grib', 'wb') as new_file, b 阅读全文

posted @ 2020-12-17 09:24 闹不机米 阅读(668) 评论(0) 推荐(0) 编辑

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示