自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(12)
  • 收藏
  • 关注

原创 python 文件

'''打开文件'r'(默认)只读打开 'w'写入方式打开(存在文件会覆盖) 'a'写入方式打开(存在文件会末尾追加)'b'二进制模式打开 't'文本模式 '+'可读写模式(可添加到其他模式中) 'U'通用换行符支持文件对象方法f.close() 关文件 f.read()读 f.readline() f.write(str)写 f.seek(offset,from)移 f.tell()指...

2018-05-20 02:08:27 110

原创 python 代理ip

import urllib.requestimport randomurl = 'http://www.whatismyip.com'iplist = ['61.135.217.7:80','114.249.63.193:8118','114.236.44.33:61234','111.183.228.246:61234','121.232.146.65:8118']#多搞几个ip 换着...

2018-05-18 20:38:04 403

转载 urllib.request.Request理解Request

import urllib.request#可以将url先构造成一个Request对象,传进urlopen #Request存在的意义是便于在请求的时候传入一些信息,而urlopen则不request = urllib.request.Request('http:response = urllib.request.urlopen(requeprint(response.read().de...

2018-05-18 18:07:11 1007

转载 python标准库urllib.parse.urlencode的应用

python标准库urllib.parse.urlencode的应用1、urllib标准库一共包含以下子包:urllib.error    由urllib.request引发的异常类urllib.parse    URL解析组件urllib.request    用于打开网址的可扩展库。urllib.response    urllib使用的响应类。urllib.robotparser    加载...

2018-05-18 00:51:52 16886 1

原创 python 爬图和搞翻译

urllib(package)---URL + libURL三部分1.协议;http,https,ftp,file,ed2k...2.存放资源的服务器域名系统或IP地址(有时候要包含端口号,各个传输协议都有默认的端口号,如http的默认端口号为80)3.资源的具体地址,如目录或者文件名等''''''import urllib.requestresponse=urllib.request...

2018-05-16 23:19:33 597

转载 python encode 与decode

字符串在Python内部的表示是Unicode编码,因此,在做编码转换时,通常需要以unicode作为中间编码,即先将其他编码的字符解码(decode)成unicode,再从unicode编码(encode)成另一种编码。decode的作用是将其他编码的字符转换成unicode编码,如str1,decode('gb2312'),表示将gb2312编码的字符串str1转换成unicode编码。enc...

2018-05-16 22:33:43 166

原创 python模块

from __future__ import print_function#包就是文件夹,模块就是py文件#包与普通的目录区别在于:包下面有个__init__.py文件import math#可访问math模块中所有公开函数print(math.pow(4,2))#pow是平方函数print(math.pi)from math import pow,sin ,log #只想用某几个函...

2018-05-16 21:05:00 107

原创 python turtle

import turtle'''turtle.setup(1800,1204,0,0)#窗口 (宽,高,位置(0,0)在左上角)turtle.pensize(10)turtle.pencolor('yellow')turtle.seth(-60)#运行方向turtle.fd(80)turtle.circle(-90,400)'''def main(): turtle.set...

2018-05-14 15:28:26 533

原创 python字符串

s='python is best'#所有的改变方法 生成一个新的字符串 s不变a=s.upper()print(a)b=a.lower()print(b)print(b.capitalize)c=b.capitalize()print(c)t=' strip\n'r=t.strip()print(t)print(r)r='5423'print(r.isdigit...

2018-05-14 15:26:49 113

原创 python列表

L=['b','c','d','a']print(L[1])print(L[0]+L[1])print(2*L)print(len(L[2:]))for i in L: print(i)print('a' in L)L.append('python')print(L)L.reverse()print(L)print(L.index('python'))L...

2018-05-14 15:23:52 86

原创 python异常处理

捕捉到出错 防止报错 更人性化try:    number1,number2=eval(input('enter two numbers:'))    result=number1/number2except ZeroDivisionError:    print("Division by zero! = =")except SyntaxError:    print("A comma may b...

2018-05-14 15:21:07 141

原创 python面向对象

#_*_ coding:utf-8 _*_class Dog: color='yellow' def __init__(self,name,age,height): self.name = name self._age = age self.__height = height def get__height(self): ...

2018-05-11 23:12:19 91

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除