![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
yunshouhu
爱Java,更爱Android,学VC,搞c/c++的我。专注移动安全,游戏安全,逆向安全!十年戎马成神路,君临天下风雷动! https://github.com/yunshouhu
展开
-
pthon学习之小例子
1、九九乘法表'''Created on 2013-12-6@author: Administrator'''#python 实现九九乘法表if __name__ == '__main__': #for i in range(1, 10, 1): # print i #for i in range(10): # print i f原创 2013-12-06 16:00:28 · 1279 阅读 · 0 评论 -
python 异常处理
#!/usr/bin/python# -*- coding: UTF-8 -*-try: fh = open("testfile.txt", "w") fh.write("这是一个测试文件,用于测试异常!!")except IOError: print "Error: 没有找到文件或读取文件失败"else: print "内容写入文件成功" fh.原创 2016-07-27 16:01:49 · 458 阅读 · 0 评论 -
python通用模块使用例子
#!/usr/bin/python# -*- coding: UTF-8 -*-__author__ = 'Administrator'import osimport sysimport shutilimport struct#python通用模块使用例子result=os.system("pwd");print (type(result));print("val="+st原创 2016-07-27 17:55:53 · 943 阅读 · 0 评论 -
浅析Python中的struct模块
先附上源码:#!/usr/bin/python# -*- coding: UTF-8 -*-__author__ = 'Administrator'#需要有一种机制将某些特定的结构体类型打包成二进制流的字符串然后再网络传输,# 而接收端也应该可以通过某种机制进行解包还原出原始的结构体数据。python中的struct模块就提供了这样的机制,#python struct的pack和转载 2016-07-27 18:13:57 · 1110 阅读 · 0 评论 -
python string转换为tuple (by list)
#!/usr/bin/python# -*- coding: UTF-8 -*-__author__ = 'Administrator'import structeval("""__import__("os").system('echo "hello"')"""),print eval("(1,2,3)", dict(__builtins__=None))values = (1, '原创 2016-07-28 09:31:25 · 4727 阅读 · 0 评论 -
python getopt的使用
#!/usr/bin/python# -*- coding: UTF-8 -*-import sysimport getoptdef usage(): print("usage");def main(): try: opts, args = getopt.getopt(sys.argv[1:], "ho:v", ["help", "output="])原创 2016-08-22 20:28:16 · 970 阅读 · 0 评论 -
python demo之print格式化输出
#!/usr/bin/env python# Python Network Programming Cookbook -- Chapter - 1# This program requires Python 2.7 or any later versionimport socketfrom binascii import hexlifydef convert_ip4_address原创 2016-09-17 22:29:24 · 967 阅读 · 0 评论 -
python之pip的使用
pip国内镜像:http://pypi.doubanio.com/simple/window 直接设置国内源:import osini="""[global]index-url = https://pypi.doubanio.com/simple/[install]trusted-host=pypi.doubanio.comdisable-pip-version-che原创 2016-09-18 21:04:14 · 1463 阅读 · 0 评论 -
python技巧之目录遍历
import sys import platform import osfrom subprocess import * if len(sys.argv)!=2: print("arg error, "+sys.argv[0]+" input_dir"); exit(1)input_dir=sys.argv[1];if os.path.isfile(input_di原创 2016-09-18 11:39:20 · 721 阅读 · 0 评论 -
python 多线程demo
#coding=utf-8import threadimport time# 为线程定义一个函数def print_time( threadName, delay): count = 0 while count < 5: time.sleep(delay) count += 1 print "%s: %s" % ( threadName,原创 2016-10-09 00:29:10 · 1077 阅读 · 0 评论 -
python之简单排序文本文件
import sysimport platformimport osfrom subprocess import *if len(sys.argv) != 2: print("arg error, " + sys.argv[0] + " input_file"); exit(1)input_file = sys.argv[1];fp = open(input_fi原创 2016-11-05 10:26:59 · 2845 阅读 · 0 评论 -
python多线程端口扫描器
#!/usr/bin/env pythonimport socketimport sysimport threadingimport timeNORMAL = 0ERROR = 1TIMEOUT = 5def ping(ip , port , timeout=TIMEOUT): try: cs=socket.socket(socket.AF_INET,socket.SOC转载 2017-01-05 18:00:08 · 1047 阅读 · 0 评论 -
python调用window dll和linux so例子
#!/usr/bin/python# -*- coding: UTF-8 -*-#python dll.pyimport win32api# 打开记事本程序,在后台运行,即显示记事本程序的窗口win32api.ShellExecute(0, 'open', 'notepad.exe', '','',1)import win32processwin32process.CreatePro原创 2017-01-09 11:46:40 · 2794 阅读 · 0 评论 -
python json转化操作
#!/usr/bin/python# -*- coding: UTF-8 -*-import jsonimport sysimport os'''重要函数编码:把一个Python对象编码转换成Json字符串 json.dumps()解码:把Json格式字符串解码转换成Python对象 json.loads()'''#http://www.cnblogs.com/lol原创 2017-04-01 16:25:55 · 654 阅读 · 0 评论 -
python实现http post四种请求体x-www-form-urlencoded ,form-data ,json,xml
HTTP 协议规定 POST 提交的数据必须放在消息主体(entity-body)中,但协议并没有规定数据必须使用什么编码方式。常见的四种编码方式如下: 1、application/x-www-form-urlencoded 这应该是最常见的 POST 提交数据的方式了。浏览器的原生 form 表单,如果不设置 enctype 属性,那么最终就会以 application/x-www-fo原创 2017-04-01 17:06:18 · 21061 阅读 · 2 评论 -
Python error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat)解决方案
转自:http://blog.csdn.net/liwugang43210/article/details/50732920http://blog.csdn.net/ylh071032/article/details/53435793python通过pip或者源码来安装某些模块时,这些模块包含有c/c++源码,安装过程会调用本地的编译器编译这些代码。在Windows平台下我安装转载 2017-10-16 01:20:19 · 723 阅读 · 0 评论 -
python面向对象例子
#!/usr/bin/python# -*- coding: UTF-8 -*-__author__ = 'Administrator'#面向对象class Person: count=0; def __init__(self,name,age): self.name=name; self.age=age; Student.原创 2016-07-27 15:47:17 · 2028 阅读 · 1 评论 -
Python Demo
解析ifconfig命令的标准输出,返回网卡名称和对应的ip# -*- coding: utf-8 -*- #!/usr/bin/python#奇虎运营实习第二题,使用python实现#解析ifconfig命令的标准输出,返回一个hash。key是网卡名称 value是对应的ipimport osimport socket import fcntl import struct d原创 2016-06-26 14:44:25 · 1771 阅读 · 0 评论 -
python简单实现linux命令strings
# -*- coding: utf-8 -*-import redef strings(file) : chars = r"A-Za-z0-9/\-:.,_$%'()[\]<> "; shortestReturnChar = 4; regExp = '[%s]{%d,}' % (chars, shortestReturnChar); pattern = re.原创 2016-05-03 15:44:31 · 1465 阅读 · 0 评论 -
python学习笔记之密码高强度加密
__author__ = 'Administrator'#coding=utf-8import hashlibimport base64def strxor(a, b): # xor two strings of different lengths if len(a) > len(b): return "".join([chr(ord(x) ^ ord(y原创 2015-04-18 23:33:20 · 2483 阅读 · 0 评论 -
Python3学习笔记之基础教程
参考网站:http://www.w3cschool.cc/python3/python3-tutorial.html__author__ = 'Administrator'import subprocesscmd="cmd.exe"begin=101end=200while begin<end: p=subprocess.Popen(cmd,shell=True,stdou原创 2015-04-11 22:12:29 · 1827 阅读 · 0 评论 -
python3之多线程和tkinter gui
#coding=utf-8import _threadimport time# 为线程定义一个函数def print_time( threadName, delay): count = 0 while count < 15: time.sleep(delay) count += 1 print ("%s: %s" % (threadNam原创 2015-04-12 20:53:45 · 6332 阅读 · 1 评论 -
python2学习笔记之mysql连接,中文乱码的解决和文件api的使用
__author__ = 'Administrator'# encoding=utf-8#http://www.w3cschool.cc/python/python-mysql.htmlimport MySQLdbdb=MySQLdb.connect(host="localhost",user="root",passwd="mysql0774mysql",db="itcast",ch原创 2015-04-12 22:42:35 · 1007 阅读 · 0 评论 -
Python3学习笔记之基础教程二
fibo.py__author__ = 'Administrator'def fib(n): a,b=0,1 while b<n: print(b,end=' ') a,b=b,a+b print()def fib2(n): result=[] a,b=0,1 while b<n: result原创 2015-04-12 12:20:05 · 755 阅读 · 0 评论 -
python2学习笔记之py2exe使用
http://www.cnblogs.com/jans2002/archive/2006/09/30/519393.html一、简介py2exe是一个将python脚本转换成windows上的可独立执行的可执行程序(*.exe)的工具,这样,你就可以不用装python而在windows系统上运行这个可执行程序。py2exe已经被用于创建wxPython,Tkinter,Pmw,Py原创 2015-04-12 21:58:45 · 995 阅读 · 0 评论 -
Python2学习笔记之gui和安装demjson库
__author__ = 'Administrator'#coding=utf-8#python2 Tkinter guiimport Tkinterdef center_window(w=300, h=200): # get screen width and height ws = root.winfo_screenwidth() hs = root.winf原创 2015-04-12 21:44:12 · 4008 阅读 · 0 评论 -
Python实用库收集
50个很棒的Python模块,包含几乎所有的需要:比如Databases,GUIs,Images, Sound, OS interaction, Web,以及其他。推荐收藏。 Graphical interfacewxPythonhttp://wxpython.org Graphical interfacepyGtk原创 2015-04-13 09:56:00 · 3617 阅读 · 0 评论 -
python2学习笔记之查看API接口、http的使用
__author__ = 'Administrator'#encoding=utf-8from ctypes import *msvcrt=cdll.msvcrtmessage_str="hello word\n"#msvcrt.dll的导出函数msvcrt.printf("Testing %s",message_str);#学习新的ctypes库 先查看API接口,可以 开始->所原创 2015-04-13 10:28:15 · 7639 阅读 · 0 评论 -
Python2学习笔记之实现ping和which源码
which.py__author__ = 'Administrator'__doc__ = """Author: kuiyuyou@gmail.comFile: aoiwhich.py"""import sysimport osdef find_executable(program): """ Given |program| which is the name or原创 2015-04-13 11:48:30 · 1205 阅读 · 0 评论 -
pyqt demo
# -*- coding: utf-8 -*-"""Module implementing MyDialog."""from PyQt4.QtCore import pyqtSignaturefrom PyQt4.QtGui import QDialogfrom PyQt4.QtGui import QApplicationfrom PyQt4.QtGui import QMe原创 2015-07-13 23:21:41 · 1783 阅读 · 0 评论 -
spark python例子
# -*- coding: utf-8 -*-from __future__ import print_functionimport sysfrom operator import addfrom pyspark import SparkContext#./pyspark /home/yunshouhu/PycharmProjects/untitled/word.py /home/原创 2015-11-05 17:10:30 · 7042 阅读 · 0 评论 -
Python AES使用
#encoding:utf-8"""示例代码easy_install install pycryptopip install pycrypto 都不行要源码安装https://www.dlitz.net/software/pycrypto/修改编译器C:\Python27\Lib\distutils\msvc9compiler.py中270行指定vc编译器vcvarsall=原创 2016-01-14 11:41:24 · 8209 阅读 · 0 评论 -
python rpc client demo
#!/usr/bin/env python#coding:utf-8#coding=utf-8#!/usr/bin/python# -*- coding: utf-8 -*-#!/usr/bin/python# vim: set fileencoding=utf-8#py文件编码 https://www.python.org/dev/peps/pep-0263/import sys原创 2015-12-15 15:10:07 · 1437 阅读 · 0 评论 -
Windows环境下安装pip和easy_install
Windows环境下安装pip和easy_install先安装easy_install和setuptoolscd setuptools-18.7.1python setup.py install然后安装pipcd pip-7.1.2python setup.py install可以看到C:\Python27\Scripts目录下已经存在easy_instal原创 2015-12-03 09:53:39 · 5052 阅读 · 0 评论 -
python thrift简单例子
HelloService.thriftservice HelloService { void sayHello() string getData(1:string input) }thrift -gen py HelloService.thrift即可生成gen-pyserver.py#!/usr/bin/env python## Licensed to原创 2015-12-04 11:00:59 · 12607 阅读 · 0 评论 -
Go语言的GOPATH与工作目录详解
转自:http://www.jb51.net/article/56779.htmGOPATH设置go 命令依赖一个重要的环境变量:$GOPATH1(注:这个不是Go安装目录。下面以笔者的工作目录为说明,请替换自己机器上的工作目录。)在类似 Unix 环境大概这样设置:复制代码代码如下: export GOPATH=/home/a转载 2018-01-04 12:15:53 · 30116 阅读 · 0 评论