摘要: 最近发现了python的commands模块,查看了下源码,使用的popen封装的,形成三个函数getstatus(), getoutput(), getstatusoutput()源码如下:def getstatus(file): """Return output of "ls -ld " ... 阅读全文
posted @ 2015-01-14 10:50 熠然 阅读(6778) 评论(1) 推荐(0)
摘要: commands模块用于调用shell命令有3中方法:commands.getstatus() 返回执行状态commands.getoutput() 返回执行结果commands.getstatusoutput() 返回一个元组,执行状态和执行结果其他执行shell命令的方法还有:1.os.sy... 阅读全文
posted @ 2015-01-14 09:24 熠然 阅读(4111) 评论(0) 推荐(0)
摘要: 设置自动补全代码刚刚学Android,有很多变量和方法 都不熟悉。需要有提示,才更加方便。快捷方式:Alt + / 可以出现代码提示。默认的只有输入“ .” 以后才会有代码补全提示,可作如下设置:在Auto activation triggers for Java: 那一栏修改为“._abcdef... 阅读全文
posted @ 2015-01-11 15:49 熠然 阅读(575) 评论(0) 推荐(0)
摘要: 新建了一个虚拟机,然后发现Emulator control为灰色,让eclipse重启下就可以了,然后就可以使用了。 阅读全文
posted @ 2015-01-10 23:04 熠然 阅读(577) 评论(0) 推荐(0)
摘要: 从一位前辈的博客看到了一张图,先转过来,稍后再细看 阅读全文
posted @ 2015-01-09 20:56 熠然 阅读(195) 评论(0) 推荐(0)
摘要: 函数在Python中是第一类对象,可以当做参数传递给其他函数,放在数据结构中,以及作为函数的返回结果。下面的例子为接受另外一个函数作为输入并调用它1 #foo.py2 def callf(func):3 return func()使用上面的函数:1 import foo2 def hello... 阅读全文
posted @ 2015-01-07 22:46 熠然 阅读(255) 评论(1) 推荐(0)
摘要: Python中分为3种除法:传统除法、精确除法、地板除。传统除法:如果是整数除法则执行地板除,如果是浮点数除法则执行精确除法。>>>1/20>>>1.0/2.00.5精确除法:除法总是会返回真实的商,不管操作数是整形还是浮点型。执行from __future__ import division 指令... 阅读全文
posted @ 2015-01-07 21:57 熠然 阅读(354) 评论(0) 推荐(0)
摘要: 1 # -*- coding:utf-8 -*- 2 class Super(object): 3 4 def test(self): 5 self.action() 6 7 class Sub(Super): 8 9 def action(s... 阅读全文
posted @ 2015-01-07 10:51 熠然 阅读(819) 评论(0) 推荐(0)
摘要: 使用的python2.7,运行的时候出现了'ascii' codec can't encode characters in position 0-8: ordinal not in range(128)错误,通过搜索一些文章了解到是因为python系统使用的默认编码为ascii编码,但是代码运行中的... 阅读全文
posted @ 2014-12-13 22:04 熠然 阅读(1745) 评论(0) 推荐(0)
摘要: 1.python manage.py shell2.from django.contrib.auth.models import User3.user=User.objects.get(username='XXX')4.user.set_password('new_password')5.user.... 阅读全文
posted @ 2014-11-26 17:44 熠然 阅读(6162) 评论(0) 推荐(0)