随笔分类 - ~~python开发~~
摘要:>mac osx 下面用django-admin.py创建项目的时候,没创建成功出现django-admin.py编辑文件,这主要的原因是mac osx下面django-admin.py被重命名为django-admin`django-admin startproject mysite`
        阅读全文
                
摘要:1、安装Xcode command line tools首先,编译mysql和Homebrew需要用到Xcode command line tools,所以首先安装command line tools;如果安装了Xcode,只需要“Preferences… > Downloads”,之后点击Comm...
        阅读全文
                
摘要:出现这个问题Some externally hosted files were ignored (use --allow-external PIL to allow)的主要原因是PIL的一些依赖库还没有安装需要先安装PIL的依赖库安装步骤(1)首先通过homebrew安装libtiff,libjpe...
        阅读全文
                
摘要:在程序中要添加django.setup()整个程序如下所示import osimport djangodef populate(): python_cat = add_cat('Python') add_page(cat=python_cat, title="Officia...
        阅读全文
                
摘要:def find_defining_class(obj, method_name): for ty in type(obj).mro(): if method_name in ty.__dict__: return ty return Nonemro方法用来获得用于搜索调用方法的类对象列表
        阅读全文
                
摘要:如果不清楚一个对象是否拥有某个属性,可以使用内置函数hasattr访问一个对象的属性的方法是通过特别属性__dict__,它是一个映射,将属性名称映射到属性值为了调试方便,可以添加下面这个函数 def print_attributes(self): for attr in self.__dict__: print attr,getattr(self,attr)
        阅读全文
                
摘要:题目id: 1 just print a+bgive you two var a and b, print the value of a+b, just do it!!print a+b题目id: 2 list排序给你一个list L, 如 L=[2,8,3,50], 对L进行升序排序并输出print sorted(L)题目id: 3 字符串逆序给你一个字符串 a, 如a=‘12345’,对a进行逆序输出a。print a[::-1]题目id:4 输出字典key给你一字典a,如a={1:1,2:2,3:3},输出字典a的key,以','链接,如‘1,2,3'。print
        阅读全文
                
摘要:zip是一个内置函数, 接受两个或多个序列,并将他们拉到一起,成为一个元组列表。每个元组包含各个序列中的一个元素。s = 'abc' t = [0,1,2]zip(s,t) >>>[('a',0),('b',1),('c',2)] 如果需要遍历序列中的元素以及它们的下标,可以使用内置函数enumerate: for index,elemet in enumerate('abc'): print index,element>>> 0 a 1 b 2 c
        阅读全文
                
摘要:chr()根据整数返回对应的字符,也就是讲ascii转换为字符unichr()将整数返回成unicode字符ord()将字符转换成ascii码
        阅读全文
                

 
         浙公网安备 33010602011771号
浙公网安备 33010602011771号