摘要: join() #将分离的各部分组合成一个路径名#用法如:>>>os.path.join("c:\temp\","test.txt")'c:\\temp\\test.txt' 阅读全文
posted @ 2015-07-29 14:05 一指禅 阅读(88) 评论(0) 推荐(0) 编辑
摘要: (1).当"print os.path.dirname(__file__)"所在脚本是以完整路径被运行的, 那么将输出该脚本所在的完整路径,比如: python d:/pythonSrc/test/test.py 那么将输出 d:/pythonSrc/test(2).当"print os.path.... 阅读全文
posted @ 2015-07-29 14:01 一指禅 阅读(520) 评论(0) 推荐(0) 编辑
摘要: Django 的 ORM 有多种关系:一对一,多对一,多对多。各自定义的方式为 : 一对一: OneToOneField 多对一: ForeignKey 多对多: ManyToManyField上边的描述太过数据而缺乏人性化,我们来更人性化一些: 多个属于一个,即 belong to... 阅读全文
posted @ 2015-03-25 18:10 一指禅 阅读(585) 评论(0) 推荐(0) 编辑
摘要: Model 的 Meta 选项原文链接:http://django-chinese-docs-14.readthedocs.org/en/latest/ref/models/options.html本文介绍你能在model中使用的 class Meta 内嵌类的所有 元数据选项 (meta opti... 阅读全文
posted @ 2015-03-25 17:54 一指禅 阅读(368) 评论(0) 推荐(0) 编辑
摘要: 字段名参数意义AutoField一个能够根据可用ID自增的IntegerFieldBooleanField一个真/假(true/false)字段CharField(max_length)一个字符串字段,适用于中小长度的字符串。对于长段的文字,请使用TextFieldCommaSeparatedInt... 阅读全文
posted @ 2015-03-24 14:11 一指禅 阅读(460) 评论(0) 推荐(0) 编辑
摘要: # -*- coding: utf-8 -*-#新手程序员(递归)def factorial(x): if x == 0: return 1 else: return x * factorial(x - 1)print factorial(6)#有一年 Python 经验的程序员... 阅读全文
posted @ 2015-03-24 13:37 一指禅 阅读(545) 评论(0) 推荐(0) 编辑