
python专栏
python之路。问题解决大合集
ProblemTerminator
上行若水,大行至简
展开
-
flask框架快速搭建服务及curl访问验证
flask框架快速搭建服务及curl访问验证原创 2023-12-30 13:00:00 · 438 阅读 · 0 评论 -
一次搞定python中json与class对象互转
一次搞定python中json与class对象互转原创 2023-12-25 17:30:12 · 1510 阅读 · 0 评论 -
一次解决python报错ModuleNotFoundError: No module named ‘xxx‘
一次解决python报错ModuleNotFoundError: No module named ‘xxx‘原创 2023-12-26 09:00:00 · 704 阅读 · 0 评论 -
python对象与json字符串互转
python对象与json字符串互转原创 2023-12-27 14:00:00 · 437 阅读 · 0 评论 -
解决‘tuple‘ object has no attribute ‘lower‘
解决'tuple' object has no attribute 'lower'原创 2022-06-24 12:49:38 · 2512 阅读 · 0 评论 -
解决TypeError: Unicode-objects must be encoded before hashing
解决TypeError: Unicode-objects must be encoded before hashing原创 2022-06-24 12:48:20 · 419 阅读 · 0 评论 -
论你的python代码莫名其妙、无缘无故的终止执行的原因
python代码莫名其妙、无缘无故的终止执行的原因原创 2022-06-16 20:57:10 · 3144 阅读 · 0 评论 -
python接收命令行参数并操作
python接收命令行参数并操作原创 2022-06-10 17:32:29 · 373 阅读 · 0 评论 -
postman发送文件请求并以python服务接收
Postman发送文件请求并以python服务接收原创 2022-06-10 17:34:33 · 2046 阅读 · 0 评论 -
python对象与json字符串互转
python对象与json字符串互转原创 2022-06-10 17:37:55 · 860 阅读 · 0 评论 -
一次搞定python中json与class对象互转
一次搞定python中json与类对象互转原创 2022-06-10 17:41:49 · 3644 阅读 · 0 评论 -
python之读写配置文件:config parser模块的用法
大本营:https://blog.youkuaiyun.com/HYZX_9987项目结构(注意config的位置):创建配置文件config.ini,内容自定,格式如下:[url]host = 127.0.0.1port = 9010[session]macaronsession = 31de87b1019407f0实现对配置文件增删改查的方法(方法名称即对应的功能):......原创 2019-07-25 19:53:56 · 1455 阅读 · 0 评论 -
一次解决You should consider upgrading via the ‘pip install --upgrade pip‘ command.
在执行pip install --upgrade pip 或 python -m pip install --upgrade pip升级pip时报错:You should consider upgrading via the 'pip install --upgrade pip' command. 如下图解决办法:python -m pip install -U --force...原创 2020-04-10 10:55:26 · 14972 阅读 · 7 评论 -
flask报错AttributeError: ‘AnonymousUserMixin‘ object has no attribute ‘user_name‘
原因是当前用户未登录(未使用用户),所以找不到user_name属性。可使用if hasattr(current_user, 'user_name')来处理,当然最主要还是在认证层面做好阻挡,非法的操作不能走到后续逻辑中。原创 2022-04-23 08:40:52 · 2235 阅读 · 0 评论 -
记一次平台websocket架构调整的开发/调试/部署经历
目录背景流程概述平台ws架构图调试瞬间基于容器平台手动工作负载部署(deployment)jenkins cicd+rancher实现自动化构建部署我是人间惆怅客,知君何事泪纵横。断肠声里忆平生。背景调整前ws server由go开发,与平台后端服务融合在一起,整个过程大部分是前端与后端直接交互,为了避免这种情况,领导决定单独开发一个ws server从平台...原创 2019-12-12 19:49:52 · 1289 阅读 · 0 评论 -
解决python报错ModuleNotFoundError: No module named ‘xxx‘
解决python报错ModuleNotFoundError: No module named ‘xxx‘原创 2022-02-18 19:21:35 · 17982 阅读 · 8 评论 -
一次解决python报错ModuleNotFoundError: No module named ‘xxx‘; ‘xxx‘ is not a package
总结备忘,一次铭记解决办法。检查包名和文件是否重名,作者就是这个问题,提示的是自定义的包,将重名的改为非重名即可正常。其它原因:包下没有__init__.py文件,没有就创建一个,这个坑作者也踩过。...原创 2022-02-18 19:19:50 · 7437 阅读 · 2 评论 -
解决python导包报错ImportError: cannot import name ‘xxx‘ from
花了较长时间,最后发现循环引用导致。既然循环引用了,只要让让它们别循环引用就行。那么解决掉循环引用的部分即可正常!解决办法:1,拆解成多个文件,将要互相引用的分开2,缩小导入的范围,如一般情况下import在文件顶部,这时候可以将import移动到紧挨需要导入的代码上方即可;...原创 2022-02-18 18:24:46 · 55887 阅读 · 0 评论 -
解决python报错AttributeError: module ‘sys‘ has no attribute ‘getframe‘
在使用sys.getframe().f_code.co_name获取当前函数名称时报错。最后发现是名称不对。正确的是_getframe。即:sys._getframe().f_code.co_name原创 2022-02-18 18:05:42 · 1433 阅读 · 0 评论 -
解决python报错TypeError: ‘bool‘ object is not subscriptable
使用[ ]取值的时候,该值是一个布尔类型,而不是list,用[ ]下标当做列表来取就会报该错。即:布尔值不能用中括号下标取。原创 2022-01-21 20:19:01 · 4818 阅读 · 0 评论 -
解决ValueError: invalid literal for int() with base 10
出现这个报错,是准备将字符串转为Int导致的。原因就在于要转的不是纯数字不能转为int,仔细检查下就好了,以及获取配置getint()的情况,如果配置不是纯数字就会报错。原创 2022-01-20 09:15:40 · 1667 阅读 · 0 评论 -
No manage.py file specified in Settings->Django Support
运行Django项目时报错:No manage.py file specified in Settings->Django Support解决办法:进入settings,找到Django,勾选Enable Django Support 并配置这两项:Django project root:选直属包含manage.py的目录Settings:选settings.py文件,如图...原创 2019-10-23 16:42:36 · 4228 阅读 · 0 评论 -
解决python报错FileNotFoundError: [Errno 2] No such file or directory
解决python报错FileNotFoundError: [Errno 2] No such file or directory原创 2022-01-17 20:50:21 · 7637 阅读 · 0 评论 -
解决python报错Object of type xxx is not JSON serializable
Object of type Ip xxx is not JSON serializable其中xxx为自定义类的对象,调用json.dumps报了错。怎么解决呢? 很简单,将对象改为dict结构再转就OK了!示例:要转的对象为obj convert = dict() convert ['a'] = obj.a convert ['b'] = obj.b result = json.dumps(convert)常用类型到json的转换规则如下:Pyt原创 2022-01-17 20:38:14 · 11298 阅读 · 0 评论 -
解决AttributeError: ‘str‘ object has no attribute ‘get‘
解决python问题AttributeError: ‘str‘ object has no attribute ‘get‘原创 2019-09-05 09:30:30 · 60880 阅读 · 2 评论 -
基于flask框架快速搭建服务及curl访问验证
基于flask框架快速搭建服务及curl访问验证原创 2021-05-14 17:29:33 · 875 阅读 · 0 评论 -
解决ERROR: Cannot uninstall ‘requests‘. It is a distutils installed project and thus we cannot
解决ERROR: Cannot uninstall 'requests'. It is a distutils installed project and thus we cannot原创 2022-10-03 08:15:00 · 1594 阅读 · 0 评论 -
解决python报错TypeError: ‘tuple‘ object does not support item assignment
解决python报错TypeError: ‘tuple‘ object does not support item assignment原创 2019-09-05 09:30:23 · 54163 阅读 · 0 评论 -
python问题记录IndentationError: unindent does not match any outer indentation level
大本营:https://blog.youkuaiyun.com/HYZX_9987缩进级别不匹配:python严格控制代码行缩进,点击报错时最下面那行的行数,看看代码中哪里缩进不正确即可。原创 2019-09-05 09:37:22 · 633 阅读 · 0 评论 -
python之异步函数执行:类似于go中的defer
简要举例:import timeimport threadingdef click(func,*args,**kwargs): func print 'callback over'def callback(): time.sleep(3) print 'i am callback' def anc(func): t = threa...原创 2019-07-20 15:11:30 · 1358 阅读 · 1 评论 -
‘python‘不是内部或外部命令,也不是可运行程序或批处理文件
‘python‘不是内部或外部命令,也不是可运行程序或批处理文件原创 2019-11-17 16:31:28 · 1735 阅读 · 0 评论 -
‘pip‘ 不是内部或外部命令,也不是可运行的程序
前提:安装完python后如果根目录下没有scripts文件夹是不行的,不能进行pip操作,该问题的解决请移步:python目录下没有Scripts文件夹/不能进行pip操作解决办法:将你的python安装的根目录的scripts路径复制下来,然后修改环境变量:桌面 计算机--属性--高级系统设置--环境变量--双击用户变量中的path如我的是D:\devFrom\python2....原创 2019-11-17 16:27:35 · 3246 阅读 · 0 评论 -
python对**kwargs的实践和理解
关键字参数的作用: 它可以扩展函数的功能。比如,在person函数里,我们保证能接收到name和age这两个参数,但是,如果调用者愿意提供更多的参数,我们也能收到。试想你正在做一个用户注册的功能,除了用户名和年龄是必填项外,其他都是可选项,利用关键字参数来定义这个函数就能满足注册的需求。它允许传入0个或任意个含参数名的参数,这些关键字参数在函数内部自动组装为一个dict。如:...原创 2019-07-20 15:20:43 · 527 阅读 · 0 评论 -
解决pyinotify ERROR] add_watch: cannot watch
解决pyinotify ERROR] add_watch: cannot watch原创 2019-07-20 14:49:19 · 2071 阅读 · 0 评论