Chinaunix首页 | 论坛 | 博客
  • 博客访问: 104451
  • 博文数量: 67
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 577
  • 用 户 组: 普通用户
  • 注册时间: 2014-04-16 09:51
个人简介

啄木鸟专吃虫,故名啄木鸟。

发布时间:2014-05-23 10:14:02

os.system('command')#运行系统命令例如:os.system('logcat -d')无返回os.popen()#执行命令还返回执行后的信息对象例如:for line in os.popen('adb shell pm list package').readlines():......【阅读全文】

阅读(395) | 评论(0) | 转发(0)

发布时间:2014-05-23 10:05:20

>>> a = ['i','am','a','big','apple']>>> b = ['you','are','a','apple']>>> print list(set(a).intersection(set(b)))#两个list求交集['a', 'apple']>>> print [s for s in b if s in a]#两个list求交集方法2['a', 'apple']>>> print list(set(a).union(set(b)))#两个list求并集['a', 'appl.........【阅读全文】

阅读(665) | 评论(0) | 转发(0)

发布时间:2014-05-15 19:17:59

>>> os.getcwd()#函数得到当前工作目录,即当前Python脚本工作的目录路径。'D:\\installed\\python2.7.6'os.remove("D:/screenshot.png")函数用来删除一个文件。os.system("adb logcat>D:/mi/log.txt")#函数用来运行shell命令。os.getcwd():获得当前工作目录os.curdir:返回但前目录('.')>>> os.curdir'.'>>> o.........【阅读全文】

阅读(485) | 评论(0) | 转发(0)

发布时间:2014-05-14 11:47:14

#somescript.pyimport systext = sys.stdin.read()#读取sys.stdin中的内容,如在管道中使用:  cat somefile.txt | somescript.py就可以计算somefile中的单词数words = text.split()wordcount = len(words)print 'Wordcount:',wordcount......【阅读全文】

阅读(206) | 评论(0) | 转发(0)

发布时间:2014-05-08 17:30:51

f = open(filename)while True:    char = f.read(1)#读一个字符,以字符为单位进行循环;若改为:char = f.readline(),则是一行为单位进行循环    if not char:break#读到最后,返回空时,跳出循环    print charf.closef = open(filename)for char in f.read(.........【阅读全文】

阅读(302) | 评论(0) | 转发(0)
给主人留下些什么吧!~~
留言热议
请登录后留言。

登录 注册