- 博客(18)
- 收藏
- 关注
原创 tkinter中的Label组件
from tkinter import *root=Tk()#创造TK(窗口)对象textLabel = Label(root,text="这是一个菊花哦!\n而且还是红色的",justify=LEFT,padx=10)#创造在窗口内的标注对象textLabel.pack(side=LEFT)#位置自动photo=PhotoImage(file="juhua.png")imgLabel=Label...
2018-06-27 22:00:11 461
原创 第一个最简单的tkinter
import tkinterapp=tkinter.Tk()#创建Tk窗口对象app.title("my first tkinter")#窗口标题thelabel=tkinter.Label(app,"我的窗口")#label组件thelabel.pack()# 自动调节组件位置尺寸app.mainloop()#进入主循环...
2018-06-27 20:52:13 358
原创 filter,map,reduce
filter为python的高阶函数,江湖人称过滤器 通过函数筛选为True的结果filter刷选出True(符合条件的部分)的结果 filter(function or None,iterable) -->filter object>>> filter(None,[0,1,2,False,True])<filter object at 0x03A4B930>...
2018-06-23 21:35:20 183
原创 lambda表达式
lambda参数:return的表达式>>> def ds(x): return 2*x+2>>> ds(2)6>>> lambda x:2*x+2<function <lambda> at 0x031514F8>>>> g = lambda x:2*x+2>>
2018-06-23 20:45:47 424
转载 sudo命令无法用
切换到root用户,运行visudo命令2在打开的配置文件中,找到root ALL=(ALL) ALL,在下面添加一行xxx ALL=(ALL) ALL 其中xxx是你要加入的用户名称3输入:wq保存并退出配置文件,再次使用sudo命令就不会有上面的提示了...
2018-06-06 00:04:32 734
原创 css基础
CSS规则:选择器,一个或者多个声明h1 {color:red; font-size:14px;}选择器 {属性 :值; 属性 : 值;}
2018-06-04 01:51:10 157
原创 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 131
原创 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 574
转载 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 1032
转载 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 16968 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 611
转载 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 192
原创 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 116
原创 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 545
原创 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 121
原创 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 107
原创 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 163
原创 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 100
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人