首页
学习
活动
专区
工具
TVP
发布

代码伴一生

专栏成员
74
文章
74945
阅读量
12
订阅数
python通过代理服务器访问ftp服务
proxy_info = { 'host' : 'proxy.myisp.com', 'port' : 3128, } proxy_support = urllib2.ProxyHandler({"ftp" : % proxy_info}) opener = urllib2.build_opener(proxy_support) urllib2.install_opener(opener)
代码伴一生
2021-11-03
1.8K0
python通过httplib发送GET和POST请求代码
python有一个httplib的库,提供了很方便的方法实现GET和POST请求,只需要简单的组织一下即可。
代码伴一生
2021-11-03
9820
python生成随机密码或随机字符串
python生成随机密码或随机字符串 import string,random def makePassword(minlength=5,maxlength=25): length=random.randint(minlength,maxlength) letters=string.ascii_letters+string.digits # alphanumeric, upper and lowercase return ''.join([random.choice(letters)
代码伴一生
2021-11-03
1.4K0
python模拟Get请求保存网易歌曲的url
#coding:utf-8 import requests import json url = 'http://music.163.com//api/dj/program/byradio?
代码伴一生
2021-11-03
1.2K0
python中字典dict的常用操作方法
下面的python代码展示python中字典的常用操作,字典在python开发中有着举足轻重的地位,掌握字典操作相当重要
代码伴一生
2021-11-03
5680
Python 发送带附件的email
from email.MIMEText import MIMEText from email.MIMEMultipart import MIMEMultipart import smtplib mail_host = 'smtp.126.com' mail_user = 'xx@126.com' mail_pwd = 'xx' mail_to = 'xxzhao@gmail.com' msg = MIMEMultipart() att = MIMEText(open('d:\a.txt','rb').rea
代码伴一生
2021-11-03
8320
Python实现图标锁定到Windows任务栏或删除图标
此处使用到了Windows接口,Python中调用windows接口,可以使用win32com
代码伴一生
2021-11-03
6640
python用来获得图片exif信息的库代码
下面的代码演示的是调用方法。 # library test/debug function (dump given files) if name == 'main': import sys import getopt # parse command line options/arguments try: opts, args = getopt.getopt(sys.argv[1:], "hqsdt:v", ["help", "quick", "strict", "debug", "s
代码伴一生
2021-11-03
5980
python通过pil生成图片验证码
# -- coding: utf-8 -- 导入三个模块 import Image,ImageDraw,ImageFont import random import math '''基本功能''' 图片宽度 width = 100 图片高度 height = 40 背景颜色 bgcolor = (255,255,255) 生成背景图片 image = Image.new('RGB',(width,height),bgcolor) 加载字体 font = ImageFont.truetype('FreeSan
代码伴一生
2021-11-03
5110
python开发的简单窗口界面的倒计时界面
下面的代码通过Tkinter制作windows窗口界面,然后时间了一个简单的倒计时功能,代码可以直接运行
代码伴一生
2021-11-03
8840
Python文件、目录的一些操作(新增、移动、删除)
创建文件: os.mknod("test.txt") #创建孔文件 open("test.txt",w) #直接打开一个文件,如果文件不存在则创建文件 创建目录: os.mkdir("file") 复制文件 shutil.copyfile("oldfile","newfile") #oldfile 和 newfile 都只能是文件 shutil.copy("oldfile","newfile") #oldfile 只能是文件夹,newfile 可以使文件,也可以是目录 复制文件夹 shutil.co
代码伴一生
2021-11-02
8330
Python实现文件的压缩及解压
当我们遇到大量小文件的传输时,一般会涉及到文件的压缩和解压,下面对zip的压缩解压直接上代码
代码伴一生
2021-11-02
6710
C# 计算输入汉字的GBK编码,十六进制数输出
C# 计算输入汉字的GBK编码,十六进制数输出 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace getCode { class Program { &nbsp; /// <summary> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /
代码伴一生
2021-11-02
9690
验证码C#实现代码
using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Drawing; //powered by http://outofmemory.cn/ name
代码伴一生
2021-11-02
5590
python压缩和读取.tar.bz2格式的压缩包
python可以通过tarfile模块压缩和解压.tar.bz2包 #压缩文件夹为 .tar.bz2 import tarfile import bz2 archive = tarfile.open('myarchive.tar.bz2','w:bz2') archive.debug = 1 # Display the files beeing compressed. archive.add(r'd:\myfiles') # d:\myfiles contains the files
代码伴一生
2021-11-02
5140
python实现简单的soap客户端
# $Id: testquote.py 2924 2006-11-19 22:24:22Z fredrik $ delayed stock quote demo (www.xmethods.com) from elementsoap.ElementSOAP import * class QuoteService(SoapService): url = "http://66.28.98.121:9090/soap&quot; # Put webservice URL here. def g
代码伴一生
2021-11-02
6740
tornado实现文件下载的代码
获取请求参数;请求参数生成json格式,存入文件;下载json文件 class SpockDataIntegrationDownloadHandler(tornado.web.RequestHandler): def post(self): selectname = self.get_argument('selectname') json_string = {} """ 将请求参数放到dict中 """ type = self.g
代码伴一生
2021-11-02
8150
python获取Windows特殊文件夹路径代码
有时候你想给你的程序添加桌面快捷方式,但却连桌面的准确路径都不知道,还好微软的API给出了一些特殊文件夹路径的获取方法,再利用python的win32com模块(非标准库)即可在python中实现同样的操作!
代码伴一生
2021-11-02
1.1K0
Python模拟键盘输入和鼠标操作
一、Python键盘输入模拟: import win32api import win32con win32api.keybd_event(17,0,0,0)  #ctrl键位码是17 win32api.keybd_event(86,0,0,0)  #v键位码是86 win32api.keybd_event(86,0,win32con.KEYEVENTF_KEYUP,0) #释放按键 win32api.keybd_event(17,0,win32con.KEYEVENTF_KEYUP,0) 附个键位码表:
代码伴一生
2021-11-02
1.5K0
Python分段下载文件
下载较大文件时分段下载会加速下载过程,几乎所有下载软件都有类似的特性。在python中如何实现分段下载文件呢?
代码伴一生
2021-11-02
6700
点击加载更多
社区活动
AI代码助手快速上手训练营
鹅厂大牛带你玩转AI智能结对编程
Python精品学习库
代码在线跑,知识轻松学
博客搬家 | 分享价值百万资源包
自行/邀约他人一键搬运博客,速成社区影响力并领取好礼
技术创作特训营·精选知识专栏
往期视频·千货材料·成员作品 最新动态
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档