中午,公司太吵,闲着无聊,用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()