随笔分类 -  python 学习

python 基础学习
摘要:a='this is a'b=a.replace('a','b') 字符串替换c='this is %s %s' %('my','apple')d='this is {} {} ' .format('my','apple')e='this is {1} {0} ' .format('apple','... 阅读全文
posted @ 2015-09-01 23:25 robotor 阅读(185) 评论(0) 推荐(0)
摘要:Python paramiko多线程执行命令的脚本,加入了threading多线程,执行起来感觉效率很一般,有时候线程还会等待延迟。据说别人测试的数据,Python多线程中每个时刻只有1个线程运行,每个逻辑CPU利用率都很低,只是有时候换换CPU运行。虽然不知道别人怎么观察的,不过执行起来确实慢,耗... 阅读全文
posted @ 2015-06-08 15:55 robotor 阅读(2892) 评论(2) 推荐(0)
摘要:2015-06-02#!/usr/bin/env python#encoding:utf-8d={'a':1,'b':2}print dprint d.get('a')d.pop('a')print dkey=[1,2,3,4,50]s=set(key)print ss.add(78)print s... 阅读全文
posted @ 2015-06-02 23:11 robotor 阅读(206) 评论(0) 推荐(0)
摘要:1.用python读取csv文件:csv是逗号分隔符格式 一般我们用的execl生成的格式是xls和xlsx 直接重命名为csv的话会报错:Error:linecontains NULL byteinsun解决方案:出错原因是直接是把后缀为xls的execl文件重命名为csv的 正常的要是另存为cs... 阅读全文
posted @ 2015-05-25 18:19 robotor 阅读(387) 评论(0) 推荐(0)
摘要:python 安装paramiko 模块1.下载PyCrypto2.6 for Python 2.7 32bit 可以正常使用地址为 http://www.voidspace.org.uk/python/modules.shtml#pycrypto2.下载安装ecdsa-0.10.tar.gz,地址... 阅读全文
posted @ 2015-05-25 14:00 robotor 阅读(374) 评论(0) 推荐(0)
摘要:1、split 分割2、内置函数 __name__ ------- 主动执行还是被其他程序调用; 本程序内 __name__ 值为 __main__ ;其他程序调用时,__文件名____file__ ======当前文件路径、是文件的相对路径__doc__ ======当前程序说明文档3、函数 de... 阅读全文
posted @ 2015-05-24 20:01 robotor 阅读(184) 评论(0) 推荐(0)
摘要:阅读目录1. 使用base642. 使用pycrypto模块回到顶部1. 使用base64s1 = base64.encodestring('hello world')s2 = base64.decodestring(s1)print s1, s2结果12aGVsbG8gd29ybGQ=hello ... 阅读全文
posted @ 2015-05-23 01:18 robotor 阅读(293) 评论(0) 推荐(0)
摘要:python 安装easy_install和pipeasy_install和pip都是用来下载安装Python一个公共资源库PyPI的相关资源包的首先安装easy_install下载地址:https://pypi.python.org/pypi/ez_setup解压,安装.python ez_set... 阅读全文
posted @ 2015-05-05 18:27 robotor 阅读(246) 评论(0) 推荐(0)
摘要:python 中自定义函数 使用def 即define ;后面跟上函数名称;及();括号中放入的是参数,可以为空自定义 sum,计算list 中元素的平方和def square_of_sum(L): sum = 0 for x in L: sum = sum + x * x... 阅读全文
posted @ 2015-01-18 19:06 robotor 阅读(2656) 评论(0) 推荐(0)
摘要:sum、计算和,此函数传入的参数是listL = []x = 1while x >> cmp(1, 2)-1>>> cmp(2, 1)1>>> cmp(3, 3)0abs、绝对值>>> abs(100)100>>> abs(-20)20>>> abs(12.34)12.34 阅读全文
posted @ 2015-01-18 18:18 robotor 阅读(265) 评论(0) 推荐(0)
摘要:创建个子字典 用大括号 {}字典是包括 key 和valued = { 'Adam': 95, 'Lisa': 85, 'Bart': 59}print 'Adam:',d.get('Adam')print 'Lisa:',d.get('Lisa')print 'Bart:',d.... 阅读全文
posted @ 2015-01-18 12:47 robotor 阅读(215) 评论(0) 推荐(0)
摘要:for x in [ '1','2','3','4','5','6','7','8','9']: for y in ['0', '1','2','3','4','5','6','7','8','9' ]: if x<y: print x+y 阅读全文
posted @ 2015-01-18 10:59 robotor 阅读(448) 评论(0) 推荐(0)