-
python线程同步
所属栏目:[Python] 日期:2020-12-17 热度:76
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 #!/usr/bin/python import threadingimport time class myThread (threading.Thread): def __init__(self,threadID,name,counter): threading.Thread.[详细]
-
python多线程模块threading使用范例代码
所属栏目:[Python] 日期:2020-12-17 热度:97
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 #!/usr/bin/python import threadingimport time exitFlag = 0 class myThread (threading.Thread): def __init__(self,threadID,name,counter): thre[详细]
-
python通过MySQLdb模块连接查询mysql数据
所属栏目:[Python] 日期:2020-12-17 热度:89
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 #!/usr/bin/python import MySQLdb # Open database connectiondb = MySQLdb.connect("localhost","testuser","test123","TESTDB" ) # prepare a curs[详细]
-
python操作mysql数据库的简单示例
所属栏目:[Python] 日期:2020-12-17 热度:160
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 #!/usr/bin/python import MySQLdb # Open database connectiondb = MySQLdb.connect("localhost","testuser","test123","TESTDB" ) # prepare a curs[详细]
-
一个python自定义的加密解密函数
所属栏目:[Python] 日期:2020-12-17 热度:62
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 def encrypt(key,s): b = bytearray(str(s).encode("gbk")) n = len(b) # 求出 b 的字节数 c = bytearray(n*2) j = 0 for i in range(0,n): b1 = b[i][详细]
-
python正常时间和unix时间戳时间的相互转换代码
所属栏目:[Python] 日期:2020-12-17 热度:140
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 这段代码可以用来转换常规时间格式为unix时间戳,也可以将unix时间戳转换回来 # -*- coding: utf-8 -*- import time def timestamp_datetime(value):[详细]
-
python csv
所属栏目:[Python] 日期:2020-12-17 热度:67
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 #! /usr/bin/env pythonimport csvimport sysimport codecsdef handler_line(src_list): desc_list = [] for item in src_list: print item desc_list[详细]
-
原 第三方Linux版网易云音乐 出新版了
所属栏目:[Python] 日期:2020-12-17 热度:159
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 print('I love music.') 以上是编程之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。 如果觉得编程之家网站内[详细]
-
python寻找1~n以内(包括n)所有素数
所属栏目:[Python] 日期:2020-12-17 热度:114
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 def find_prime(n): L = list(range(2,n + 1)) m = 0 while m len(L): n = m + 1 while n len(L): if L[n]%L[m] == 0: del L[n] n = n + 1 m = m + 1[详细]
-
使用python中的matplotlib进行绘图分析数据
所属栏目:[Python] 日期:2020-12-17 热度:135
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 快速绘图 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 # coding=gbk '' ' Created on Jul 12 , 2014 py[详细]
-
python在windows下操作word的方法
所属栏目:[Python] 日期:2020-12-17 热度:61
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 import win32comfrom win32com.client import Dispatch,constants w = win32com.client.Dispatch('Word.Application')# 或者使用下面的方法,使用启动[详细]
-
去掉当前目录下电影名字前的框框
所属栏目:[Python] 日期:2020-12-17 热度:76
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 #!/usr/bin/env python# -*- coding:utf-8 -*-import os,redef main():fileList=os.listdir(os.getcwd())p=re.compile('[.*]')for fileName in file[详细]
-
python基础教程代码分享
所属栏目:[Python] 日期:2020-12-17 热度:129
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 people = {'Alice' : {'phone' : '2341','addr' : 'Foo drive 23'},'Beth' : {'phone' : '9102','addr' : 'Bar Street 42'},'Cecil' : {'phone' : '31[详细]
-
python分解质因数
所属栏目:[Python] 日期:2020-12-17 热度:198
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 from math import *#判断n是否为素数def isprime(n):if n = 1:return 0m = int(sqrt(n))+1for x in range(2,m):if n%x == 0:return 0return 1#利用递[详细]
-
Python3.4 PIL的使用
所属栏目:[Python] 日期:2020-12-17 热度:58
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 from PIL import Image,ImageFilter,ImageDraw,ImageFont,ImageEnhance,ImageFilter image1 = Image.open('C:/Users/hengli/Desktop/1.jpg') image2 =[详细]
-
python通过Tkinter显示网络图片
所属栏目:[Python] 日期:2020-12-17 热度:128
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 ''' tk_image_view_url_io.pydisplay an image from a URL using Tkinter,PIL and data_streamtested with Python27 and Python33 by vegaseat 01mar2[详细]
-
python通过PyGame绘制图像并保存为图片文件
所属栏目:[Python] 日期:2020-12-17 热度:175
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 ''' pg_draw_circle_save101.pydraw a blue solid circle on a white backgroundsave the drawing to an image filefor result see http://prntscr.co[详细]
-
python通过wxPython打开并播放wav文件
所属栏目:[Python] 日期:2020-12-17 热度:171
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 ''' wx_lib_filebrowsebutton_sound.pyselect a sound file and play itwx.lib.filebrowsebutton.FileBrowseButton(parent,labelText,fileMask)(combi[详细]
-
python arp欺骗伪造网关代码
所属栏目:[Python] 日期:2020-12-17 热度:70
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 #coding:utf-8'''arp欺骗局域网pc,将伪造的网关mac以网关的arp应答发送给pc'''from scapy.all import ARP,send,arpingimport sys,re stdout=sys.stdo[详细]
-
python从网络下载文件并获得文件大小、文件类型
所属栏目:[Python] 日期:2020-12-17 热度:81
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 import urllib2from settings import COOKIES opener = urllib2.build_opener() cookies = ";".join("%s=%s" % (k,v) for k,v in COOKIES.items())ope[详细]
-
python将文本转换成图片输出
所属栏目:[Python] 日期:2020-12-17 热度:146
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 #-*- coding:utf-8 -*- from PIL import Image,ImageFont,ImageDraw text = u'欢迎访问open-open.com' font = ImageFont.truetype("msyh.ttf",18) lin[详细]
-
linux下通过python获得指定网卡的ip地址
所属栏目:[Python] 日期:2020-12-17 热度:176
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 import socketimport fcntlimport struct def get_ip_address(ifname): """ get_ip_address('lo') '127.0.0.1' get_ip_address('eth0') '38.113.228.1[详细]
-
python编写的最简单的web服务器
所属栏目:[Python] 日期:2020-12-17 热度:138
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 import SocketServer class MyRequestHandler(SocketServer.BaseRequestHandler): def handle(self): print "From:",self.client_address input = sel[详细]
-
python从ftp服务器下载文件
所属栏目:[Python] 日期:2020-12-17 热度:99
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 import ftplibftp = ftblib.FTP("ftp.yourServer.com")ftp.login("username","password")filename = "index.html"ftp.storlines("STOR " + filename,o[详细]
-
python提交post数据到远程url
所属栏目:[Python] 日期:2020-12-17 热度:136
今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 import sys,urllib2,urllib zipcode = "S2S 1R8"url = 'http://www.wunderground.com/cgi-bin/findweather/getForecast'data = urllib.urlencode([('q[详细]
