包含标签 python 的文章

python2.7版本tuple中的中文编码问题

在处理向mysql插入中文字符的过程中,碰到这样一个问题,明明是utf-8编码的中文str ,但是到了mysql里面显示的并不是中文,而是该中文字符串的utf-8编码的十六进制形式,下面是整个解决过程。 中文字符正常情况下应该是这样的: >>> a = '中文123' >>> print(a) 中文12……

阅读全文

wxPython学习笔记

A wx.Frame is a top-level window. When people talk about GUIs, they usually speak of windows, menus and icons. Naturally then, you would expect that wx.Window should represent a window on the screen. Unfortunately, this is not the case. A wx.Window is the base class from which all visual elements are derived (buttons, menus, etc) and what we normally think of as a program window is a wx.Frame. This is an unfortunate inconsistency that has led to much confusion for new users. Within a frame, you'll use a number of wxWindow sub-classes to flesh out the frame's contents. Here are some of the more common elements you might want to put in your frame: A wx.MenuBar, which puts a menu bar along the top of your frame. A wx.StatusBar, which sets up an area along the bottom of your frame……

阅读全文

flask学习笔记

当前工作路径 操作系统有进程当前工作目录的概念。不幸的是,你在 Web 应用中不能依赖此概念,因为你可能会在相同的进程中运行多个应用。 为此,提供了 app.root_path 属性以获取应用的路径。配合 os.path 模块使用,轻松可达任意文件 配置 a cleaner solution would be to create a separate .ini or .py file and load that or import the values from there.……

阅读全文

python装饰器学习

装饰器的的几种用途: 注入参数(提供默认参数,生成参数) 记录函数行为(日志、缓存、计时什么的) 预处理/后处理(配置上下文什么的) 修改调用时的上下文(线程异步或者并行,类方法)……

阅读全文

python的from-import机制

在使用Python的过程中,我遇到了这么一个有关模块导入的bug。 先说我的目录结构 core foo.py bar.py shit.py fuck.py __init__.py (对,这就是我的目录结构😂) 其中fuck.py里import了shit和bar,shit和bar里都import了foo,但是import的方式是不一样的,所有文件内容如下: # fuck.py import shit import bar……

阅读全文