会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
LarryKnight
博客园
首页
新随笔
联系
管理
订阅
随笔分类 -
Python Study
1
2
下一页
python中的动态变量
摘要:def make_name(): names = locals() for i in range(1, 10): names['t%s' % i] = i print names['t%s' % i]
阅读全文
posted @
2016-11-25 17:56
LarryKnight
阅读(1011)
评论(0)
推荐(0)
python的string用法
摘要:s.strip().lstrip().rstrip(',') S.lower() #小写 S.upper() #大写 S.swapcase() #大小写互换 S.capitalize() #首字母大写 #分割 s = 'ab,cde,fgh,ijk'print(s.split(',')) #连接 d
阅读全文
posted @
2016-08-08 13:28
LarryKnight
阅读(644)
评论(0)
推荐(0)
python中在同一个位置输出数据
摘要:import sys, time def print_data(): for i in range(5): sys.stdout.write(str(i) + '\r') time.sleep(1) sys.stdout.flush() if __name__ == '__main__': print_data()
阅读全文
posted @
2016-07-27 23:05
LarryKnight
阅读(2180)
评论(1)
推荐(0)
python中main()函数写法
摘要:顶顶大名的Guido van Rossum(Python之父)推荐的main写法: getopt模块用于抽出命令行选项和参数,也就是sys.argv。 命令行选项使得程序的参数更加灵活。支持短选项模式和长选项模式 opts, args = getopt.getopt( sys.argv[1:], s
阅读全文
posted @
2016-04-24 15:11
LarryKnight
阅读(45568)
评论(0)
推荐(0)
python中requests
摘要:#发送无参数的get请求import requests def get_html(url): res = requests.get(url) return res.text #发送无参数的post请求 import requests def get_html(url): res = requests.post(url) return res.text...
阅读全文
posted @
2016-04-23 11:03
LarryKnight
阅读(178)
评论(0)
推荐(0)
python遍历目录
摘要:os.walk() 用元组表示(dirpath, dirnames, filenames);第一个是根路径,dirpath为str类型;第二个是根路径中的文件夹,dirnames为list类型;第三个是根路径下的文件,filenames为list类型。全路径表示法:os.path.join(dirp...
阅读全文
posted @
2016-01-17 14:36
LarryKnight
阅读(215)
评论(0)
推荐(0)
wxpython颜色选择
摘要:Color CodeColor NameColor#000000BLACK#0000FFBLUE#007FFFSLATE BLUE#00FF00GREEN#00FF7FSPRING GREEN#00FFFFCYAN#23238ENAVY#236B8ESTEEL BLUE#238E23FOREST G...
阅读全文
posted @
2016-01-11 15:18
LarryKnight
阅读(1662)
评论(1)
推荐(0)
python获取文件时间
摘要:import time, oscreate_time = time.ctime(os.path.getctime(filename))modify_time = time.ctime(os.path.getmtime(filename))
阅读全文
posted @
2016-01-04 19:57
LarryKnight
阅读(1094)
评论(0)
推荐(0)
python中的binascii
摘要:import binascii as Bs = 'abcde'h = B.b2a_hex(s) # 字符串转16进制 '6162636465'h = B.hexlify(s) # 作用同上s = B.a2b_hex(h) # 16进制转字符串 'abcde's = B.unhe...
阅读全文
posted @
2015-12-30 11:08
LarryKnight
阅读(11773)
评论(0)
推荐(0)
python中文处理
摘要:源码文件为utf-8格式 CODEC='utf-8';VS在“高级保存选项”中选择“UTF-8 65001”input(u'中文');print(u'中文')
阅读全文
posted @
2015-12-29 15:57
LarryKnight
阅读(189)
评论(0)
推荐(0)
python中的popen和subprocess
摘要:import osfrom subprocess import Popen, PIPEres = os.popen('xx.exe E:\\test\\file1 E:\\test\\file2')print res.read()ps = Popen("xx.exe E:\\test\\file1 ...
阅读全文
posted @
2015-12-29 15:44
LarryKnight
阅读(365)
评论(0)
推荐(0)
python读取指定内存的内容
摘要:import ctypes as ctt = ct.string_at(0x211000, 20) # (addr, size)print t最好不要用解释性语言来开发底层,一般用C。
阅读全文
posted @
2015-11-10 23:10
LarryKnight
阅读(3668)
评论(0)
推荐(0)
IP的正则表达式
摘要:首先分析IP地址0-255:0-9: [0-9]或 \d表示数字10-99: [1-9]\d100-199: 1/d{2}200-249: 2[0-4]\d250-255: 25[0-5]简单介绍一些可以组合的符号:?问号表示0或一个字符. 点号表示任意一个字符*星号表示0或多个字...
阅读全文
posted @
2015-06-19 17:35
LarryKnight
阅读(483)
评论(0)
推荐(0)
python中的异常处理
摘要:主要用到 try...except...raise...finally...1. try...except...try: for i in range(1, 1000): print i time.sleep(1)except KeyboardInterrupt: ...
阅读全文
posted @
2015-06-10 16:30
LarryKnight
阅读(241)
评论(0)
推荐(0)
python中的类变量、实例变量
摘要:类变量,是各个实例共享的资源,就像中央空调,只有一个,但每个房间(实例)均可享用。 实例变量,是每个实例各自分配使用的变量,每个房间(实例)都有一台空调,供自己使用。 class handle(object): instance_num = 100 id = 0 def _...
阅读全文
posted @
2015-05-18 11:27
LarryKnight
阅读(322)
评论(0)
推荐(0)
python中的md5加密
摘要:import md5import typesdef get_md5(data): if type(data) is not types.StringType: # 检验输入的数据是否为字符串 print 'Data must be type' r...
阅读全文
posted @
2015-05-12 14:29
LarryKnight
阅读(1391)
评论(0)
推荐(0)
python中join的用法
摘要:str.join(sequence) # 将序列中的元素以str字符连接生成一个新的字符串list1 = ['a', 'b', 'c']new_str = '-'.join(list1) # 输出 a-b-c注意列表中的数据须为str类型
阅读全文
posted @
2015-04-30 09:42
LarryKnight
阅读(373)
评论(0)
推荐(0)
python中字符串与列表的相互转换
摘要:列表转字符串 list1 = ['abc' , 'def' , 'ghi'] str1 = ','.join(list1) str1 = '##'.join(list1) 字符串转列表 str1 = ('abc,def,ghi') list1 = str1....
阅读全文
posted @
2015-04-27 15:53
LarryKnight
阅读(483)
评论(0)
推荐(0)
python中cPickle的用法
摘要:import cPickle as pf = file('data.txt' , 'w')data = (1 , 'A' , "hello")p.dump(data , f) # 将数据保存到本地文件中f.close()f = file('da...
阅读全文
posted @
2015-04-27 10:31
LarryKnight
阅读(724)
评论(0)
推荐(0)
python中列表的操作
摘要:list1 = ['A' , 'B' , 'C']list1[0] ; list1[-1] # 取第一个和最后一个元素list1[ : ] ; list1[ : len(list1)] # 取所有列表元素list1[0 : n] # 从第0号...
阅读全文
posted @
2015-04-23 21:57
LarryKnight
阅读(3065)
评论(0)
推荐(0)
1
2
下一页
公告