Government and Economics

When looking at the two topics that govern the economy most people forget about government and economics. They are simply not the same, although a lot of confuse each terms. In actuality each goes hand in hand of course, if one falls flat it impacts on the various other.

Government and economics overall are concerned with how cash is created, how it is used, and how it is used. A federal government entity like the United States government is the main gamer in both aspects. Government authorities around the world try to stimulate economic activity by simply creating programs such as deficits dataroomoid.com to acquire the economy going again. These types of deficits are used to invest in facilities, to make buys from other countries, and also to finance various programs. The government then gathers the property taxes that were paid out and disburses them through interest or other means.

Economists study these programs and endeavors to determine how well they may affect the total economy. People is also privy to these details, as there are news publications that analyze the us government and economy on a daily basis. A very important factor that many people don’t understand is that authorities and economics are often reviewed together plus the two are usually interchanged. A teacher could discuss the main topic of government and economics using their students, plus the topic can also come up during discussions within a classroom topic.

Computer Engineering Technology Is Increasing

Computer Technological innovation technology is certainly concerned with creating and designing machinery and other equipment for the use of personal computers. In today’s world, Personal computers and technology have become a major part of just about every person’s life. This discipline deals with the design, development, produce, and utilization of computers and computer related equipment. College students interested in pursuing this course need to possess creativity, good decision-making skills, and a good educational backdrop. Some normal courses for many who wish to follow a career in this field are Power and Laptop Engineering, Personal computers Technology, and Software System.

In order to be eligible to apply for a Laptop Engineering Technology major, particular requirements should be met. Imagination is a person major consideration that draws many learners to this particular important. Computer system and technical skills are very required to be able to succeed in Pc Engineering Technology. Additionally , imaginative minds are attracted to this major as a result of way impressive in this discipline is often is usually.

However , there are plenty of things you can do to organize yourself to get a computer system technology main. In high school graduation, you may want to take classes just like math, scientific discipline, and browsing. You may also wish to consider interning or working by a company with computer technology so you can gain hands-on mergersacquisitions.eu encounter.

爬虫基础

首先,我们要搞懂一个东西。那就是网页,当我们登录一个网址时,可以看到一个光鲜亮丽的网页,构成它的就是一些代码,这种代码称之为HTML,是一种浏览器看得懂的语言。通过浏览器将这种语言转化成我们能够看到的网页。
同时除了HTML以外还可以使用CSS跟JavaScript。
其次,关于简单的爬虫所需要用到的库有:urllib.request中的urlopen,BeautifulSoup,request,re。
首先urlopen可以实现对于url的访问,并且读取其中的信息。
BeautifulSoup用以选取信息;用以代替正则表达式。

from bs4 import BeautifulSoup
from urllib.request import urlopen

# if has Chinese, apply decode()
html = urlopen("https://baidu.com").read().decode('utf-8')

soup = BeautifulSoup(html, features='lxml')
print(soup.input)

如果说HTML是框架的话,那么CSS可以理解成衣服。如果只有框架没有衣服,那么整个网页会看起来十分的死板,所以需要通过添加衣服来使得整个网页更加的绚丽多彩。
Class作为CSS的一个重要组成部分,可以简单想象成python中的class。对于每一个class都会有自己的属性如颜色大小字体等,使得每个class都不一样,让整个网页看起来更加悦目一些。因此我们可以通过查找class的具体名称来查找一类组件。

from bs4 import BeautifulSoup
from urllib.request import urlopen

# if has Chinese, apply decode()
html = urlopen("https://baidu.com").read().decode('utf-8')

soup = BeautifulSoup(html, features='lxml')

# use class to narrow search
a = soup.find_all('div', {"class": "s_tab"})
for m in a:
    print(m.get_text())

正则表达式,通过不同的正则化可以使得查找的条件更加的多样化。这里就不展开讲了。
如果只是简单的读取数据,收集信息,使用BeautifulSoup就已经差不多了,然而随着其他需求的增多,我们可能会需要下载、上传图片、发送信息等功能,这时候Request就可以用来处理这些问题。其中用于加载网页的有几种方式,其中最常见的就是get跟post两种。最大的区别就在于post可以对网站进行操作,而get除了看跟收集信息,其他的都做不了。

data = {'firstname': '莫烦', 'lastname': '周'}
r = requests.post('http://pythonscraping.com/files/processing.php', data=data)
print(r.text)

Cookies在浏览器中十分的重要,就像是缓存,记录着你的一些私人信息,如账号密码等,方便你的使用。然后在我们正常爬取数据的时候需要一次又一次的登录,每一次都需要传递cookies,过于麻烦,所以可以通过使用request中的Session来保存每一次的cookies,方便了之后的操作。

session = requests.Session()
payload = {'username': 'Morvan', 'password': 'password'}
r = session.post('http://pythonscraping.com/pages/cookies/welcome.php', data=payload)
print(r.cookies.get_dict())

# {'username': 'Morvan', 'loggedin': '1'}


r = session.get("http://pythonscraping.com/pages/cookies/profile.php")
print(r.text)

下载文件
第一种:在urllib中有一个下载功能urlretrieve,只需要输入下载地址跟存放的位置,就可以自动下载过来。
第二种:使用requests通过新建一个文件,然后将网页的文件写入其中。
第三种:也是使用requests,当我们下载较大的文件时,用第二种方法它会缓存直到整个文件都下载好了再存入硬盘里不是很方便。所以使用chunck从而实现了实时下载文件

#一 from urllib.request 
    import urlretrieve 
    urlretrieve(IMAGE_URL, './img/image1.png') 
#二 import requests 
    r = requests.get(IMAGE_URL) 
    with open('./img/image2.png', 'wb') as f: 
        f.write(r.content) 
#三 r = requests.get(IMAGE_URL, stream=True) 
    with open('./img/image3.png', 'wb') as f: 
       for chunk in r.iter_content(chunk_size=32): 
           f.write(chunk)

多进程分布式爬虫
当我们正常使用爬虫的时候,它是一个线性的过程,只有等到这一个爬完了,才会到另一个地方爬另外的东西。这样子,再等待的过程中,浪费了好多的时间。因此使用多进程分布式爬虫可以有效地减缓时间的浪费,最大化的利用电脑。

异步线程爬虫
其主要原理都相差不多,都是通过抽出在执行过程中浪费的时间来提高爬虫效率。

高级爬虫scrapy 相当于专门用于爬虫的库
对于scrapy还有大量的知识没有掌握,这里不做太多的介绍,如果之后还有继续学习爬虫的话,会去认真看看scrapy的!!!

参考链接:https://mofanpy.com/tutorials/data-manipulation/scraping/

python小项目-图片转化视频

用到了cv2、os、PIL 三个库

在弄视频转化字符动画时自己弄出来的代码。

import cv2
import os
from  PIL import  Image

fps = 3
img_root = 'E://python_text//'

data = os.listdir(img_root) #保存当前目录文件列表

image = Image.open(img_root+'pi0.png')

fourcc = cv2.VideoWriter_fourcc('m','p','4','v')
videoWriter = cv2.VideoWriter('tett1.mp4',fourcc,fps,image.size)

num = 0
for i in data:
    ##print(i)
    print(i)
    if i == 22:
        break
    if i.endswith('.png'):
        frame = cv2.imread(img_root+'pi'+str(num)+'.png')
        num += 1
        videoWriter.write(frame)
videoWriter.release()
cv2.destroyAllWindows()

 

 

python小项目-视频转化成字符动画(高级)

结合了之前所实现的视频转化字符动画,由于其在Pycharm上面显示不能够连贯逐帧显示,只能放在shell里面去运行,过于麻烦,所以对其进行了相应的改进。再加上之前所学习的将字符串转化成图片的经验,这次直接将视频转化成字符视频。

原理

  1. 通过之前的步骤将每一帧的图像以字符串的形式保存在列表当中;
  2. 将每一帧的字符串保存为图片
  3. 同时将读取之前保存的图片逐步转化成视频即可
import cv2
import os
from PIL import  Image,ImageDraw,ImageFont

show_heigth = 50
show_width = 150

ascii_char = list("$@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/\|()1{}[]?-_+~<>i!lI;:,\"^`'. ")

char_len = len(ascii_char)

def get_char(r,g,b,alpha = 256):
    if alpha == 0:
        return ' '
    length = len(ascii_char)
    gray = int(0.2126 * r + 0.7152 * g + 0.0722 * b)
    #由于灰度大于字符 所以需要将灰度分配在不同的字符上
    unit = (256.0 + 1)/length
    return ascii_char[int(gray/unit)]

vc = cv2.VideoCapture("pi.mp4")  # 加载一个视频

if vc.isOpened():  # 判断是否正常打开
    rval, frame = vc.read()
else:
    rval = False

frame_count = 0
outputList = []  # 初始化输出列表
num = 0
while rval:  # 循环读取视频帧
    if frame_count % 5 ==0:

        cv2.imwrite('%s.jpg'%('pic_'+str(num)),frame)
        name = 'pic_' + str(num)+'.jpg'

        im = Image.open(name)
        im = im.resize((show_width, show_heigth), Image.NEAREST)
        num += 1

        text = ""

        for i in range(show_heigth):
            for j in range(show_width):
                text += get_char(*im.getpixel((j,i)))#*可以传递元组
            text += '\n'
        outputList.append(text)
        os.remove(name)

    frame_count = frame_count + 1
    rval, frame = vc.read()
print("处理完毕")

num = 0

fourcc = cv2.VideoWriter_fourcc('m','p','4','v')
fps = 3
videoWriter = cv2.VideoWriter('tett2.mp4',fourcc,fps,(show_width*8,show_heigth*16))
for frame in outputList:
    
    font = ImageFont.load_default()
    im_txt = Image.new('L', (show_width * 8, show_heigth * 16), 255)
    d = ImageDraw.Draw(im_txt)
    d.text((0, 0), frame, font=font)

    im_txt.save('pi%s.jpg'%(num))

    name = 'E://python_text//'+'pi'+str(num)+'.jpg'
    i = cv2.imread(name)
    #i.show()
    videoWriter.write(i)
    os.remove(name)
    num += 1

videoWriter.release()
cv2.destroyAllWindows()

心得:
对于如何将图片合成视频有了一定的了解以及os一些删除、显示等功能

fourcc = cv2.VideoWriter_fourcc('m','p','4','v') #视频编码格式
videoWriter = cv2.VideoWriter('tett2.mp4',fourcc,fps,(show_width*8,show_heigth*16))
i = cv2.imread(name)
videoWriter.write(i)  #将图片写了视频中

 

python小项目-视频转化成字符动画(初级)

这次的所有代码都是基于之前所作的小项目图片转化成字符图,这次进行功能上面的提升,能够转化视频输出为字符动画。
想到视频第一反应肯定是opencv,这里所使用的程序库有Pillow、argparse、cv2、os

思路:同样的首先定义好命令行的参数,获取输入视频的路径、长宽;
之后定义好能够将图片RGB值转化成之前设定好的字符串列表的函数;
通过cv2来截取每一帧的视频并保存为图片格式;
逐个保存并逐个读取;
通过getchar函数去获得每一个字符图,并用字符列表来保存。
最后由于IDLE输出起来不是特别的顺畅,所以在shell中使用,来实现字符动画。

import cv2
import os
from PIL import  Image
import argparse


#命令行输入参数处理
parser = argparse.ArgumentParser()

parser.add_argument('file')     #输入文件
parser.add_argument('-o', '--output')   #输出文件
parser.add_argument('--width', type = int, default = 150) #输出字符画宽
parser.add_argument('--height', type = int, default = 80) #输出字符画高

#获取参数
args = parser.parse_args()

video = args.file
show_width = args.width
show_heigth = args.height

ascii_char = list("$@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/\|()1{}[]?-_+~<>i!lI;:,\"^`'. ")

char_len = len(ascii_char)

def get_char(r,g,b,alpha = 256):
    if alpha == 0:
        return ' '
    length = len(ascii_char)
    gray = int(0.2126 * r + 0.7152 * g + 0.0722 * b)
    #由于灰度大于字符 所以需要将灰度分配在不同的字符上
    unit = (256.0 + 1)/length
    return ascii_char[int(gray/unit)]

vc = cv2.VideoCapture(video)  # 加载一个视频

if vc.isOpened():  # 判断是否正常打开
    rval, frame = vc.read()
else:
    rval = False

frame_count = 0
outputList = []  # 初始化输出列表
num = 0
while rval:  # 循环读取视频帧
    if frame_count % 5 ==0:

        cv2.imwrite('%s.jpg'%('pic_'+str(num)),frame)
        name = 'pic_' + str(num)+'.jpg'

        im = Image.open(name)
        im = im.resize((show_width, show_heigth), Image.NEAREST)
        num += 1
        text = ""

        for i in range(show_heigth):
            for j in range(show_width):
                text += get_char(*im.getpixel((j,i)))#*可以传递元组
            text += '\n'
        outputList.append(text)

    frame_count = frame_count + 1
    rval, frame = vc.read()
print("处理完毕")

for frame in outputList:
    os.system("cls")  # 清屏
    print(frame)
    print()
    print()

知识点:对于cv2程序库有了一点点的认识,也算是自己单独去将图片转化成字符图升级成字符动画。

vc = cv2.VideoCapture(video)  #加载一个视频
rval , frame  = vc.read()            #读取视频的帧以及图像
cv2.imwrite(‘%s.jpg’%(‘pic_’+str(num)),frame) #将视频的图像以pic_’num’.jpg的形式保存

优化:

根据参考文献,知道了opencv可以直接将每一帧的图像转化成灰度图,然后通过resize以及get_char函数能够直接得到相对应的字符图

while rval:  # 循环读取视频帧
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)  # 使用opencv转化成灰度图
    gray = cv2.resize(gray, (show_width, show_heigth))  # resize灰度图
    text = ""
    for pixel_line in gray:
        for pixel in pixel_line:  # 字符串拼接
            text += ascii_char[int(pixel / 256 * char_len)]
        text += "\n"
    outputList.append(text)
    frame_count = frame_count + 1
    if frame_count % 100 == 0:
        print("已处理" + str(frame_count) + "帧")
    rval, frame = vc.read()
print("处理完毕")

 

 

参考文献:https://www.cnblogs.com/youmuchen/p/8299109.html

python小项目-图片转化成字符图

代码完成将一张图片转化成字符的图。
使用的程序库有 Pillow、argparse。
效果图如下:

思路:首先定义好命令行的参数,能够获取输入图片的路径、图片的长宽、以及输出的文件名;
之后定义能够将图片RGB值转化成之前设定好的字符串列表的函数;
遍历图片的每一个点,通过字符串保存所有的转化后的结果,并以txt格式输出。

# -*- coding=utf-8 -*-
from PIL import Image
import argparse

#命令行输入参数处理
parser = argparse.ArgumentParser()

parser.add_argument('file')     #输入文件
parser.add_argument('-o', '--output')   #输出文件
parser.add_argument('--width', type = int, default = 80) #输出字符画宽
parser.add_argument('--height', type = int, default = 80) #输出字符画高

#获取参数
args = parser.parse_args()

IMG = args.file
WIDTH = args.width
HEIGHT = args.height
OUTPUT = args.output

ascii_char = list("$@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/\|()1{}[]?-_+~<>i!lI;:,\"^`'. ")

# 将256灰度映射到70个字符上
def get_char(r,g,b,alpha = 256):
    if alpha == 0:
        return ' '
    length = len(ascii_char)
    gray = int(0.2126 * r + 0.7152 * g + 0.0722 * b)
    #由于灰度大于字符 所以需要将灰度分配在不同的字符上
    unit = (256.0 + 1)/length
    return ascii_char[int(gray/unit)]

if __name__ == '__main__':

    im = Image.open(IMG)
    im = im.resize((WIDTH,HEIGHT), Image.NEAREST) # Image.NEAREST表示输出低质量的图片

    txt = ""
    # 逐行遍历提取每个单位的RGB值
    for i in range(HEIGHT):
        for j in range(WIDTH):
            txt += get_char(*im.getpixel((j,i)))#*可以传递元组
        txt += '\n'

    print(txt)

    #字符画输出到文件
    if OUTPUT:
        with open("output.txt",'w') as f:
            f.write(txt)
    else:
        with open("output.txt",'w') as f:
            f.write(txt)

知识点:懂得了argparse库的一些函数的使用。
以及pillow库的使用。

if __name__ == ‘__main__’: 代码块中(表示如果 picture.py 被当作 python 模块 import 的时候,这部分代码不会被执行)。
parser.add_argument() 添加指令
Image.open() 打开图片
im.getpixel()  获得单位的RGB值
Image.NEAREST 输出低质量的图片

with 表达式为try-finally 的简写形式

####
格式
with context [as var]:
     pass
####
其中context是一个表达式,返回一个对象,var来保存context表达式返回的对象,可以存在一个或多个返回值

with open('1.txt') as f:
     print(f.read())

表达式open(‘1.txt’)返回一个io.TextlOWrapper类型的变量用f来接受。
在with语句块中就可以使用这个变量来操作文件。执行with之后,f会自动关闭相当于自带finally。
但是with本身没有捕获异常的功能,不论是否发生异常都会照常关闭文件。

优化:
由于之前通过保存在txt文件当中来进行查看图片是否转化成字符图,不仅有些许的繁琐,而且由于文本格式的问题会出现图像变形。所以了解了如何将字符图保存为图片的形式显示出来,所以添加了一些代码,使得在程序运行的时候就可以看到字符图,相较于打开文件来说方便了许多,也更加的直观。
实例如图:

from PIL import ImageDraw,ImageFont

    font = ImageFont.load_default()
    im_txt = Image.new('L', (WIDTH*8,HEIGHT*16), 255)
    d = ImageDraw.Draw(im_txt)
    d.text((0,0),txt,font = font)
    im_txt.show()
    im_txt.save('dog1.png')

 

参考文献:https://www.cnblogs.com/csnd/p/11526150.html

Python小项目–简易计算器

第一次尝试去做一个小的项目,去设计一个简易的计算器,能够实现加减乘除、回退、清零等步骤就可以了。

因此需要用到tkinter这个图形开发界面库,大致上了解了一下库中常用的一些函数如:button(按钮)、label(标签)等。

效果图如下:

思路:首先参考系统自带的计算器,对于整个计算器的框架、位置以及大小进行一个设置。讲整个计算器分为三个部分:显示部分、数字按钮、操作按钮。
显示部分用两个label来实现,一个用来显示整个计算过程,一个用来显示结果和数字。
数字按钮就是用来输入数字。
操作按钮就是用来执行操作如:AC、回退、+-*/=等操作

定义一个列表用来存储每次的按键以及一个用来判断是否按下符号的标志。
设置一个数字函数,判断是否按下数字按钮,并获取数字显示在显示器上。
设置一个操作函数,当按下操作按钮的时候,获取数字和符号,放入列表中。如果为’AC’,清零列表并将数字设置成默认值0.如果为’Back’,就将字符串回退一位。
当按下=时,将列表当中的字符串通过eval()来进行计算得出计算结果并输出到显示屏上面。

实例:

import tkinter as tk

root  = tk.Tk()
root.minsize(280,500)
root.title('计算器')

result1 = tk.StringVar()
result1.set(0)
result2 = tk.StringVar()
result2.set('')

label = tk.Label(root,font = ('微软雅黑',20),bg = '#EEE9E9',bd ='9',fg = '#828282',anchor = 'se',textvariable = result2)
label.place(width = 280,height = 170)
label2 = tk.Label(root,font = ('微软雅黑',30),bg = '#EEE9E9',bd ='9',fg = 'black',anchor = 'se',textvariable = result1)
label2.place(y = 170,width = 280,height = 60)


#数字键按钮

btn7 = tk.Button(root,text = '7',font = ('微软雅黑',20),fg = ('#4F4F4F'),bd = 0.5,command = lambda : pressNum('7'))
btn7.place(x = 0,y = 285,width = 70,height = 55)
btn8 = tk.Button(root,text = '8',font = ('微软雅黑',20),fg = ('#4F4F4F'),bd = 0.5,command = lambda : pressNum('8'))
btn8.place(x = 70,y = 285,width = 70,height = 55)
btn9 = tk.Button(root,text = '9',font = ('微软雅黑',20),fg = ('#4F4F4F'),bd = 0.5,command = lambda : pressNum('9'))
btn9.place(x = 140,y = 285,width = 70,height = 55)

btn4 = tk.Button(root,text = '4',font = ('微软雅黑',20),fg = ('#4F4F4F'),bd = 0.5,command = lambda : pressNum('4'))
btn4.place(x = 0,y = 340,width = 70,height = 55)
btn5 = tk.Button(root,text = '5',font = ('微软雅黑',20),fg = ('#4F4F4F'),bd = 0.5,command = lambda : pressNum('5'))
btn5.place(x = 70,y = 340,width = 70,height = 55)
btn6 = tk.Button(root,text = '6',font = ('微软雅黑',20),fg = ('#4F4F4F'),bd = 0.5,command = lambda : pressNum('6'))
btn6.place(x = 140,y = 340,width = 70,height = 55)

btn1 = tk.Button(root,text = '1',font = ('微软雅黑',20),fg = ('#4F4F4F'),bd = 0.5,command = lambda : pressNum('1'))
btn1.place(x = 0,y = 395,width = 70,height = 55)
btn2 = tk.Button(root,text = '2',font = ('微软雅黑',20),fg = ('#4F4F4F'),bd = 0.5,command = lambda : pressNum('2'))
btn2.place(x = 70,y = 395,width = 70,height = 55)
btn3 = tk.Button(root,text = '3',font = ('微软雅黑',20),fg = ('#4F4F4F'),bd = 0.5,command = lambda : pressNum('3'))
btn3.place(x = 140,y = 395,width = 70,height = 55)
btn0 = tk.Button(root,text = '0',font = ('微软雅黑',20),fg = ('#4F4F4F'),bd = 0.5,command = lambda : pressNum('0'))
btn0.place(x = 70,y = 450,width = 70,height = 55)

#运算符号按钮
btnac = tk.Button(root,text = 'AC',bd = 0.5,font = ('黑体',20),fg = 'orange',command = lambda :pressCompute('AC'))
btnac.place(x = 0,y = 230,width = 70,height = 55)
btnback = tk.Button(root,text = '←',font = ('微软雅黑',20),fg = '#4F4F4F',bd = 0.5,command = lambda:pressCompute('b'))
btnback.place(x = 70,y = 230,width = 70,height = 55)
btndivi = tk.Button(root,text = '÷',font = ('微软雅黑',20),fg = '#4F4F4F',bd = 0.5,command = lambda:pressCompute('/'))
btndivi.place(x = 140,y = 230,width = 70,height = 55)
btnmul = tk.Button(root,text ='×',font = ('微软雅黑',20),fg = "#4F4F4F",bd = 0.5,command = lambda:pressCompute('*'))
btnmul.place(x = 210,y = 230,width = 70,height = 55)
btnsub = tk.Button(root,text = '-',font = ('微软雅黑',20),fg = ('#4F4F4F'),bd = 0.5,command = lambda:pressCompute('-'))
btnsub.place(x = 210,y = 285,width = 70,height = 55)
btnadd = tk.Button(root,text = '+',font = ('微软雅黑',20),fg = ('#4F4F4F'),bd = 0.5,command = lambda:pressCompute('+'))
btnadd.place(x = 210,y = 340,width = 70,height = 55)
btnequ = tk.Button(root,text = '=',bg = 'orange',font = ('微软雅黑',20),fg = ('#4F4F4F'),bd = 0.5,command = lambda :pressEqual())
btnequ.place(x = 210,y = 395,width = 70,height = 110)
btnper = tk.Button(root,text = '%',font = ('微软雅黑',20),fg = ('#4F4F4F'),bd = 0.5,command = lambda:pressCompute('%'))
btnper.place(x = 0,y = 450,width = 70,height = 55)
btnpoint = tk.Button(root,text = '.',font = ('微软雅黑',20),fg = ('#4F4F4F'),bd = 0.5,command = lambda:pressCompute('.'))
btnpoint.place(x = 140,y = 450,width = 70,height = 55)


lists = []
isPressSign = False


#数字函数
def pressNum(num):
    global lists
    global isPressSign
    if isPressSign == False:
        pass
    else:
        result1.set(0)
        isPressSign = False

    oldnum = result1.get()
    if oldnum =='0':
        result1.set(num)
    else:
        newnum = oldnum + num
        result1.set(newnum)


#运算函数

def pressCompute(sign):
    global lists
    global isPressSign
    num = result1.get()
    lists.append(num)

    lists.append(sign)
    isPressSign = True

    if sign =='AC':
        lists.clear()
        result1.set(0)
    if sign =='b':
        a = num[0:-1]
        lists.clear()
        result1.set(a)

#获取运算结果
def pressEqual():
    global lists
    global isPressSign


    curnum = result1.get()
    lists.append(curnum)

    computrStr = ''.join(lists)
    endNum = eval(computrStr)

    result1.set(endNum)
    result2.set(computrStr)
    lists.clear()

root.mainloop()

通过自身的查找文章,以及查阅博客,大致上能够代码复现出来。也算是第一次完成了一个小项目。大概了解关于tkinter的相关知识

参考文献:https://www.cnblogs.com/sunshine-long/p/7902721.html