摘要: 原文地址https://www.xuebuyuan.com/1708245.html 还有一个 BackImage 属性,但该属性是 String 类型的。 另外有一个 SaveImage 方法,而没有想要的GetImage()方法,因此只有转换一下,代码如下: using (MemoryStrea 阅读全文
posted @ 2018-08-13 18:42 神·鲸落 阅读(582) 评论(0) 推荐(0) 编辑
摘要: 选择“开始”*“运行”,输入“regedit”,打开注册表编辑器。单击 “HKEY_CLASSES_ROOT”旁边的“+”号,可以看到左边窗口中有一排文件夹,都是以Windows中应用程序建立的文件的后缀名命名的(如.doc、.xls和.html等)。找出您要增加到“新建”菜单中的文件类型的后缀名,单击鼠标右键,选择“新建”*“主键”(在注册表中,每个文件夹都是一个主键),将新的主键取名为“ShellNew”。选取新建的主键,在右边视窗空白处单击鼠标右键,选择“新增”*“字符串值”。如果您使用的文件类型,其程序预设为在启动时打开空白文件,就将新字符串名称设定为“NullFile”; 如果您使用 阅读全文
posted @ 2013-09-01 14:23 神·鲸落 阅读(1096) 评论(0) 推荐(0) 编辑
摘要: #转自:http://www.oschina.net/code/snippet_162893_24130#!/usr/bin/python# -*- coding: UTF-8 -*-# snakegameimport sysfrom PyQt4.QtCore import *from PyQt4.QtGui import *import randomclass Snake: def __init__(self): self.length = 4 self.posArray = [(3,0),(2,0),(1,0),(0,0)] self.isD... 阅读全文
posted @ 2013-08-31 13:38 神·鲸落 阅读(421) 评论(0) 推荐(0) 编辑
摘要: 转自:http://www.oschina.net/code/snippet_1174881_24083#!/usr/bin/python# -*- coding: UTF-8 -*-# -*- coding: utf-8 -*-"""Created on Sat Aug 24 15:46:11 2013@author: wangxiaotao"""import numpy as npimport matplotlib.pyplot as pltimport matplotlibF = np.arange(-50, 240, 0.1) 阅读全文
posted @ 2013-08-31 13:28 神·鲸落 阅读(525) 评论(0) 推荐(0) 编辑
摘要: 快速绘图¶使用pyplot模块绘图matplotlib的pyplot模块提供了和MATLAB类似的绘图API,方便用户快速绘制二维图表。我们先看一个简单的例子:05-matplotlib/matplotlib_simple_plot.py用pylab库快速绘图import numpy as npimport matplotlib.pyplot as plt ❶x = np.linspace(0, 10, 1000)y = np.sin(x)z = np.cos(x**2)plt.figure(figsize=(8,4)) ❷plt.plot(x,y,label="$sin( 阅读全文
posted @ 2013-08-31 13:02 神·鲸落 阅读(3139) 评论(0) 推荐(1) 编辑
摘要: import psycopsyco.full()转自:http://www.ibm.com/developerworks/cn/linux/sdk/python/charm-28/Python 对于您想让它做的事来说通常够快了。编程新手对于类似 Python 这样的解释型/字节编译型语言,将 90% 的关注点集中在执行速度方面,是相当幼稚的。在最新的硬件上,大多数非优化的 Python 程序运行的速度和所需要达到的速度一样快,而且,花费额外的编程工作以使应用程序运行得更快实在没什么意义。因此,在本文,我只对其它的百分之十感兴趣。有时,Python 程序(或用其它语言编写的程序)也会运行得极其缓 阅读全文
posted @ 2013-08-31 12:12 神·鲸落 阅读(805) 评论(0) 推荐(0) 编辑
摘要: """ PAMIE Build 3.0aBased on cPAMIE and PAM.py by RLMRevised: March 03, 2009Developers: Robert L. MarchettiDescription: This python class file allow you to write scripts to Automate the Internet Explorer Browser Client.This software is provided 'as-is', without any express or 阅读全文
posted @ 2013-08-31 00:42 神·鲸落 阅读(721) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/python# -*- coding: UTF-8 -*-#递归def print_lol(the_list): for each_item in the_list: if isinstance(each_item,list): #判断each_item 是否为列表,如果是则递归 print_lol(each_item) else: print(each_item)mo=[['a','b','c'],'c','d','s',[1,2,3,4],'e',' 阅读全文
posted @ 2013-08-31 00:34 神·鲸落 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 先将命令提示符指向安装文件所在目录然后cmdpython setup.py install 阅读全文
posted @ 2013-08-31 00:29 神·鲸落 阅读(276) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/python# -*- coding: UTF-8 -*-import matplotlib.pyplot as pltx=[i for i in range(-20,20)]y=[i**2 for i in x]# plt.plot(x,y)# plt.plot(x,y,color="red",linestyle="-.",marker="o") #linestyle="dashed"虚线 marker="o"表示标记为圆圈# plt.plot(x,y,"ro- 阅读全文
posted @ 2013-08-31 00:17 神·鲸落 阅读(359) 评论(0) 推荐(0) 编辑
摘要: 1 #!/usr/bin/python 2 # -*- coding: UTF-8 -*- 3 4 import matplotlib.pyplot as plt 5 import numpy as np 6 #To draw y =x^2 (-3<=x<=3) 7 x=[x for x in range(100)] 8 y = [ele**2 for ele in x] 9 z = [ele *2 for ele in x]10 # plt.plot(x,y,'ro-',label="y=x^2")#作图:y关于x的曲线 label是曲线标签 阅读全文
posted @ 2013-08-31 00:15 神·鲸落 阅读(284) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/python# -*- coding: UTF-8 -*-##from Tkinter import Label,mainloop##Label(text="this is a label").pack() #pack() 用几何管理器来认识控件##mainloop()from Tkinter import*class App: def __init__(self,master): frame=Frame(master)#构造器通过创建一个Frame帧窗口部件,并且把它存储在一个frame的变量中 frame.pack() ... 阅读全文
posted @ 2013-08-31 00:10 神·鲸落 阅读(314) 评论(0) 推荐(0) 编辑
摘要: #encoding=utf-8##callable()判断对象是否可以被调用a=1def b(): passprint "callable(a)",callable(a)print "callable(b)",callable(b)##结果:##callable(a) False##callable(b) True 阅读全文
posted @ 2013-08-31 00:09 神·鲸落 阅读(244) 评论(0) 推荐(0) 编辑
摘要: #encoding=utf-8#isinstance(var_a,type_b)可以确定某个变量是否有某种类型#变量var_a是否有type_b的类型.返回booleana=8b="eight"c=8.0print isinstance(a,int)print isinstance(b,str)print isinstance(c,float)print isinstance(a,str) #变量a没有str类型 阅读全文
posted @ 2013-08-31 00:08 神·鲸落 阅读(248) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/python# -*- coding: UTF-8 -*-#在新文件夹中创建一个名为setup.py的文件#包含有关发布的元数据.for distutils.core import setupsetup( name='nester', #名字 version="1.0.0", #版本号 py_modules=["nester"],#将模块的元数据与setup函数的参数关联 author="zaijie", author_email="474335983@qq.com", url 阅读全文
posted @ 2013-08-31 00:07 神·鲸落 阅读(283) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/python# -*- coding: UTF-8 -*-import threadingimport timeclass timer(threading.Thread): def __init__(self,num,interval): threading.Thread.__init__(self) self.thread_num=num self.interval=interval self.thread_stop=False def run(self): while not self.... 阅读全文
posted @ 2013-08-31 00:02 神·鲸落 阅读(396) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/python# -*- coding: UTF-8 -*-# 异常 描述# Exception 所有内建异常# SystemExit 由sys.exit()产生# StandardError 除SystemExit外所有内建异常# ArithmeticError 所有运算异常# FloatingPointError 浮点数运算异常# OverflowError 数值溢出# ZeroDivisionError ... 阅读全文
posted @ 2013-08-31 00:01 神·鲸落 阅读(449) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/python# -*- coding: UTF-8 -*-#encoding=utf-8#win32api#注册表操作# 注册表项# HKEY_CLASSES_ROOT# HKEY_CURRENT_USER# HEKY_LOCAL_MACHINE# HKEY_USERS# HKEY_CURRENT_CONFIG import win32apiimport win32con#注册表打开#RegOpenKey(key, subKey , reserved , sam)#RegOpenKeyEx(key, subKey , reserved , sam)#key: HKEY_C 阅读全文
posted @ 2013-08-30 23:58 神·鲸落 阅读(1240) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/python# -*- coding: UTF-8 -*-# 目录操作:# os.mkdir("file") 创建目录# 复制文件:# shutil.copyfile("oldfile","newfile") oldfile和newfile都只能是文件# shutil.copy("oldfile","newfile") oldfile只能是文件夹,newfile可以是文件,也可以是目标目录# 复制文件夹:# shutil.copytree("olddir" 阅读全文
posted @ 2013-08-30 23:54 神·鲸落 阅读(769) 评论(0) 推荐(0) 编辑
摘要: #encoding=utf-8##########元组的简写##################################################################t=1234,5567,"hello" #为t=(1234,5567,"hello")的简写 print tu=t,(1,2,3)print uempty=()#空元组#通过元组可以很简单的进行数据交换a=1b=2print "a,b:",a,ba,b=b,aprint "a,b:",a,b#一次赋多值v=("a&q 阅读全文
posted @ 2013-08-30 23:50 神·鲸落 阅读(240) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/python# -*- coding: UTF-8 -*-# #eg.1# #使用元组或字典的参数调用函数# def fun(a,b):# print a,b## apply(fun,("one","two"))# apply(fun,(1,2+3))#### #eg.2# #使用apply函数传递关键字参数# apply(fun,("one","two"))# apply(fun,("one",),{"b":"two"})# app 阅读全文
posted @ 2013-08-30 23:48 神·鲸落 阅读(593) 评论(0) 推荐(0) 编辑
摘要: #encoding=utf-8##encode 将对象按照指定编码进行编码。##decode 将对象按照指定编码进行解码。s="你好"s.decode("GBK")s.decode("GBK").encode("utf-8")##>>> s="你好"##>>> s.decode("GBK")##u'\u4f60\u597d'##>>> s.decode("gbk").encode(&qu 阅读全文
posted @ 2013-08-30 23:44 神·鲸落 阅读(276) 评论(0) 推荐(0) 编辑
摘要: print eval("__import__('os').getcwd()")# print eval("__import__('os').remove('file')") 阅读全文
posted @ 2013-08-30 23:42 神·鲸落 阅读(217) 评论(0) 推荐(0) 编辑
摘要: #encoding=utf-8# math包from math import *#2个常量#math.e # 自然常数e# math.pi # 圆周率piprint eprint pi# 此外,math包还有各种运算函数 (下面函数的功能可以参考数学手册):# math.ceil(x) # 对x向上取整,比如x=1.2,返回2# math.floor(x) # 对x向下取整,比如x=1.2,返回1# math.pow(x,y) # 指数运算,得到x的y次方# math.log(x) # 对数,默认基底为e。可以使用base参数,来改变对数的基... 阅读全文
posted @ 2013-08-30 23:40 神·鲸落 阅读(431) 评论(0) 推荐(0) 编辑
摘要: ###集合是无序的,不重复的元素集,类似数学中的集合,可进行逻辑运算和算术运算。#无序 不重复#set([list])s=set(['a','b','c']) #集合对象sprint "集合s的长度",len(s)print 'a' in sprint 'd' not in ss1=set([1,2,3,4,5])s2=set([1,2,3,4,5,6,7])print "s1是否s2的子集:",s1.issubset(s2),"子集:等价于s1=s2" 阅读全文
posted @ 2013-08-30 23:24 神·鲸落 阅读(391) 评论(0) 推荐(0) 编辑
摘要: #encoding=utf-8#enumerate 是python中的内置函式#enumerate(iterable) #适合for循环,可以同时循环序号和元素mylist=["a","b","c","d","e","f"]print enumerate(mylist)for index,object in enumerate(mylist):print index,object#结果为#1 a#1 b#2 c#3 d#4 e#5 f #map()#函式说明map(funct 阅读全文
posted @ 2013-08-30 23:00 神·鲸落 阅读(277) 评论(0) 推荐(0) 编辑
摘要: pyinstaller2 不需要安装G:\pyinstaller2> 为pyinstaller.py所在的路径-F 表示生成单个exe文件C:\1.py 为需要转换的py文件所在路径cd.. 是上一层目录或者回车之后:最后一行为生成exe文件所在目录 阅读全文
posted @ 2013-08-30 22:44 神·鲸落 阅读(290) 评论(0) 推荐(0) 编辑
摘要: ##1. append(x) 追加到链尾。##2. extend(L) 追加一个列表,等价于+=。##3. insert(i,x) 在位置i 插入x,其余元素向后推。如果i 大于列表的长度,就在最后添加。如果i 小于0,就在最开始处添加。##4. remove(x) 删除第一个值为x 的元素,如果不存在会抛出异常。##5. reverse() 反转序列。##6. pop([i]) 返回并删除位置为i 的元素,i 默认为最后一个元素(i 两边的[]表示i 为可选的,实际不用输入)。##7. index(x) 返回x 在列表中第一次出现的位置,不存在则抛出异常。##8. count(x) 返回x 阅读全文
posted @ 2013-07-14 13:53 神·鲸落 阅读(486) 评论(0) 推荐(0) 编辑