超级简单Python Socket Server一例


中午,公司太吵,闲着无聊,用python自己跟自己说话,算是YY吧,hoho server端代码: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 # -*- coding: utf-8 -*- from socket import * import sys, time, encodings   if __name__ == ‘__main__’: if len(sys.argv) < 2: print u’请输入端口号’ else: sockobj = socket(AF_INET, SOCK_STREAM) sockobj.bind( (”, [...]

Django 1.2.1 CSRF verification failed. Request aborted.


I was getting this 403 error today while attempting to make a POST request to a view: 403 Forbidden CSRF verification failed. Request aborted. Help Reason given for failure: CSRF cookie not set. Hopefully this saves you some time because I sure wasted a lot of mine solving it.  I ended up having to add [...]

Windows平台安装Python2.6 和 MySQL-Python


Python 版本:2.6 下载地址:http://www.python.org/download/releases/2.6.1/ 下载msi文件并安装 MySQLdb版本: MySQL-python-1.2.2.win32-py2.6.exe 下载地址:http://home.netimperia.com/files/misc/MySQL-python-1.2.2.win32-py2.6.exe 参见:http://sourceforge.net/forum/forum.php?thread_id=2316047&forum_id=70460 常见问题: 1.ImportError: DLL load failed: 找不到指定的模块。 —————————————————————————————————- D:\Program Files\Python2.6>python Python 2.6.1 (r261:67517, Dec  4 2008, 16:51:00) [MSC v.1500 32 bit (Intel)] on win32 Type “help”, “copyright”, “credits” or “license” for more information. >>> import MySQLdb Traceback (most recent call last): File “<stdin>”, line 1, in <module> File [...]

django Settings cannot be imported 错误解决


在命令行中直接敲入Python命令进入交互模式,然后使用 from django.template import  Template ,Context t  = Template(“Test is {{test}}”) 会导致:ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.原因是django的配置信息没有初始化 有两种解决方法, 一种是切换到你项目或者APP所在的目录使用manage.py shell命令启动交互窗口 还有一种是手动将django的配置初始化: >>> from django.conf import settings >>> settings.configure()

Google AppEngine Launcher不能启动的解决方法


好久不玩 Google AppEngine,google 居然用WXPython整出一个带界面的GAE  server管理器,有点进步,虽然这个东西在Mac早就有了,至少现在不用在艳羡用Mac的同志了,当初我就觉得,难道google的工程师都用Mac?为啥不顾及大部分开发者呢?google真的太有个性了。down了一个到本地,结果死活加载不了项目,不停的报错,打开log一看,全是如下错误信息: Traceback (most recent call last): File “GoogleAppEngineLauncher.py”, line 42, in <module> File “wx\_core.pyc”, line 7913, in __init__ File “wx\_core.pyc”, line 7487, in _BootstrapApp File “launcher\app.pyc”, line 53, in OnInit File “launcher\app.pyc”, line 97, in _CreateModels File “launcher\maintable.pyc”, line 35, in __init__ File “launcher\maintable.pyc”, line 86, in _LoadProjects File “launcher\project.pyc”, line [...]