如何移除电路板上的元器件?

news/2024/11/8 17:50:15/

  • How To Remove Electronic Components || Soldering Tutorial

 

01 除器件


一、背景介绍

  焊接电路板是电子工程师的基本功, 将元器件从电路板上移除是电路调试过程中的基本功。 今天看到一个视频短片,作者详细介绍了对于这种密集电路板上各种元器件焊下来的技巧。 下面让我们一起来听听他的经验吧。

-4-

二、具体操作

  最简单的移除器件,就是这种表贴电阻、电容器件。 比如这里的C32电容。只要简单利用烙铁在电容两端补锡加热,便可以轻松将电容取下。 取下之后然后利用吸锡铜丝网清理焊盘, 在利用粘有清洗剂棉花球擦洗焊盘表面,为下一次焊接做准备。

-4-

  利用这种方式对于小于1206封装的电阻电容非常有效。但对于体积超过1206的器件,特别是电容器件,这种方法往往比较困难。 比如这里的胆电容,体积比较大。如果使用热风枪对它进行拆卸,热量 有可能使其损坏。 这里采用的方法就是在电容两端补锡之后,再使用两个尖头烙铁同时加热将其取下。 后面清理焊盘工作都是一样的。

-4-

  对于SOP封装的小型芯片,则需要使用热风枪来进行拆焊。 比如这里SOP8封装的芯片,先在其管脚涂抹助焊剂,然后在使用热风枪进行加热,直到可以使用尖头镊子将芯片取下。 后面使用吸锡铜网或者多股铜丝对焊盘进行清理。

-3-

  对于这种SOP8封装的芯片,也可以采用双烙铁方式将其拆焊。 先给芯片涂抹助焊剂,然后在其管脚补锡,之后在利用双烙铁将其加热取下。 焊盘上还残留了较多的焊锡。 然后在利用吸锡铜网清理焊盘,并使用洗板水进行擦洗干净。

-4-

  对于这种表贴的铝电解电容,使用热风枪拆卸很容易将其损坏,塑料底座也会融化。 利用双烙铁方法还是比较容易将其取下。只是它的焊盘连接较粗的引线,散热较快,所以需要较长的时间加热, 加热之后,在对焊盘进行清理。

-3-

  除了热风枪、双烙铁方法之外,还可以使用钳子移除这种表贴电解电容。感觉就像拔牙一样。 之后在对焊盘进行清理。 当然这种蛮力拆焊器件方法有一定的危险, 有可能损坏焊盘。 所以最安全还是利用双烙铁方法进行拆焊。 双烙铁适用于双管脚器件和SOP8封装器件。 但对于芯片下面有散热焊盘的芯片不适用,只能使用热风枪。

-7-

  拆除器件时,有时需要注意别伤及无辜。 比如需要移除的排阻旁边, 有一个塑料插座。如果使用热风枪进行移除时, 需要考虑对它的保护。 一种方法就是利用铝箔纸粘贴在插座旁边,这样就可以放心大胆利用热风枪移除排阻了。 作为对比,可以看到热风枪很容易损坏塑料插座, 这是被热风枪损坏的情况。

-7-

 

  结 ※


  文给出了在拆焊电路板元器件的过程中,需要注意的地方。 俗话说,胆大心细,多琢磨,任何技巧都有使用的场合。 掌握好热风枪、烙铁、助焊剂的品性,面对在复杂的情形都能够游刃有余。 最后别忘了对拆焊后的焊盘进行清理,修旧如旧。

-4-


拆焊专家

#!/usr/local/bin/python
# -*- coding: gbk -*-
#============================================================
# GIF2MPG.PY                     -- by Dr. ZhuoQing 2020-02-21
#
#   gif2mpg *                       # Change gif to microvideo and put image on CSDN
#   gif2mpg +                       # Change video and put file name on CSDN
#   gif2mpg .                       # Move d:\temp\1.avi to MicroVideo
#   gif2mpg /                       # Change gif to microvideo and generate hide
#                                   # move 1.wav, 1.mp3 to MicroVideo
#   gif2mpg 150|*                   # Insert multiple picture into CSDN
#   gif2mpg @,R                     # Resize select image into view size
#   gif2mpg |,P                     # Paste select image into view size
#   gif2mpg xxx c,C,\               # Copy the mpeg GIF to temp\GIF
#   gif2mpg \                       # Copy mpeg to MicroVideo and Snag GIF
#   gif2mpg \.                      # Copy mpeg to MicroVideo and Snag GIF, keep last Picture
#   gif2mpg \..                     # Copy mpeg to MicroVideo and Snag GIF, keep last Picture, Snag last GIF
#   gif2mpg \...                    # Copy mpeg to MicroVideo, SnagGIF, SnagFirst and last Picture.
#
#
# Note:
#============================================================
from head import *
import shutil
import cv2
import numpy as np
import glob
from io import BytesIO
import win32clipboard
from PIL import Image
#------------------------------------------------------------
csdn_title = '写文章-CSDN博客'
#------------------------------------------------------------
microvideo_dir = r'd:\Nutdisk\MicroVideo'
microvideo_mooc = r'd:\MooC\MicroVideo'
microvideo_flag = 0
numstr = 'GM%d'%(int(time.time()))
#------------------------------------------------------------
def send_to_clipboard(clip_type, data):win32clipboard.OpenClipboard()win32clipboard.EmptyClipboard()win32clipboard.SetClipboardData(clip_type, data)win32clipboard.CloseClipboard()
#------------------------------------------------------------
tspdropfile2pastetext()
strall = clipboard.paste().split()
AUDACITY_TITLE = 'Audacity'
audacityflag = 0
microvideo_flag = 0
#------------------------------------------------------------
def AudacitySave(fname):tspsendwindowkey(AUDACITY_TITLE, "fe", alt=1, noreturn=1)time.sleep(1)rect = tspgetwindowrect("导出音频")if sum(rect) == 0:printf("ERROR: Can not open the save dialog.\a")exit()clipboard.copy(fname)tspsendwindowkey("导出音频", "t", alt=1,noreturn=1)tspsendwindowkey("导出音频", "cm", noreturn=1)tspsendwindowkey("导出音频", "n", alt=1, noreturn=1)tspsendwindowkey("导出音频", "v", control=1, noreturn=1)tspsendwindowkey("导出音频", "s", alt=1, noreturn=1)time.sleep(1)rect = tspgetwindowrect("警告")printf(rect)if sum(rect) != 0:printf("DEBUG")time.sleep(.5)tspsendwindowkey("警告", "y", alt=1, noreturn=1)time.sleep(.5)rect = tspgetwindowrect("编辑元信息")if sum(rect) == 0:printf("ERROR: Can not open the edit dialog.\a")tspsendwindowkey("编辑元信息", "\r", noreturn=1)time.sleep(1.5)tspsendwindowkey(AUDACITY_TITLE, "tv", alt=1, noreturn=1)
#------------------------------------------------------------
def imagepastesize(fname, width, height, topdown=0):if not os.path.isfile(fname):return 1im = Image.new(mode='RGB', size=(width, height), color=(255,255,255))imshow = Image.open(fname)imwidth,imheight = imshow.sizeoffset = ((width-imwidth)//2, (height-imheight)//((topdown+1)*2))im.paste(imshow, offset)
#    im.save(r'd:\temp\%s'%os.path.basename(fname))im.save(fname)
#------------------------------------------------------------
def imageresize(fname, width, height):if not os.path.isfile(fname):return 1im = Image.new(mode='RGB', size=(width, height), color=(255,255,255))imshow = Image.open(fname)imwidth,imheight = imshow.sizeresizewidth = widthresizeheight = heightif imwidth*height > imheight*width:resizeheight = imheight*width//imwidthelse:resizewidth = imwidth*height//imheightimshow = imshow.resize((resizewidth, resizeheight))offset = ((width-resizewidth)//2, (height-resizeheight)//2)im.paste(imshow, offset)
#    im.save(r'd:\temp\%s'%os.path.basename(fname))im.save(fname)
#------------------------------------------------------------
def getgifpic():rect = tspgetviewdcrange()iddim = tspgetdopidall()tempdim = []for id in iddim:infor = tspgetinfor(id)
#        printf(id, infor)if not 'type' in infor.keys():continuetype = infor['type']if type == 11:ratio = infor['ratio']range1 = infor['range']width = int((range1[2]-range1[0])/ratio[0])height = int((range1[3]-range1[1])/ratio[1])if abs(width - rect[4]) < 10 and abs(height - rect[5]) < 10:if ratio[0] < 0.3 and ratio[1] < 0.3:tempdim.append(id)return tempdim
#------------------------------------------------------------
def changeimgrect(fname):rect = tspgetviewdcrange()img = Image.open(fname)rectwidth = rect[4]rectheight = rect[5]rectwidth = (rectwidth + 5) // 10 * 10rectheight = (rectheight + 5) // 10 * 10img = img.resize((rectwidth, rectheight))img.save(fname)
#------------------------------------------------------------
printf(sys.argv)
if len(sys.argv) == 3 or len(sys.argv) == 2:viewsize = tspgetviewsize()selid = tspgetselectid()if sys.argv[-1] == '@' or sys.argv[-1] == 'r' or sys.argv[-1] == 'R':for id in selid:filename = tspgetdopfile(id)imageresize(filename, viewsize[0], viewsize[1])tsprefreshimagebuffer()printf('\a')tsprv()exit()elif sys.argv[-1] == '#' or sys.argv[-1] == 'p' or sys.argv[-1] == 'P' or sys.argv[-1] == '|':for id in selid:filename = tspgetdopfile(id)imagepastesize(filename, viewsize[0], viewsize[1], 1)tsprefreshimagebuffer()tsprv()printf('\a')exit()
#------------------------------------------------------------
tsprefreshimagebuffer()
addhidegifpage = 0
keeplastpage = 0
if sys.argv[-1] == '\\' or sys.argv[-1] == '、':addhidegifpage = 1microvideo_flag = 1sys.argv = sys.argv[:-1]
elif sys.argv[-1] == '\\\\' or sys.argv[-1] == '、、':addhidegifpage = 1audacityflag = 1microvideo_flag = 1sys.argv = sys.argv[:-1]
elif sys.argv[-1][-1] == '\\' or sys.argv[-1][-1] == '、':sys.argv[-1] = sys.argv[-1][:-1]audacityflag = 1microvideo_flag = 1
elif sys.argv[-1] == '\\.' or sys.argv[-1] == '、。':addhidegifpage = 1microvideo_flag = 1sys.argv = sys.argv[:-1]keeplastpage = 1
elif sys.argv[-1] == '\\\\.' or sys.argv[-1] == '、、。':addhidegifpage = 1audacityflag = 1microvideo_flag = 1keeplastpage = 1sys.argv = sys.argv[:-1]
elif sys.argv[-1] == '\\..' or sys.argv[-1] == '、。。':addhidegifpage = 1microvideo_flag = 1sys.argv = sys.argv[:-1]keeplastpage = 2
elif sys.argv[-1] == '\\\\..' or sys.argv[-1] == '、、。。':addhidegifpage = 1audacityflag = 1microvideo_flag = 1keeplastpage = 2sys.argv = sys.argv[:-1]
elif sys.argv[-1] == '\\...' or sys.argv[-1] == '、。。。':addhidegifpage = 1microvideo_flag = 1sys.argv = sys.argv[:-1]keeplastpage = 3
elif sys.argv[-1] == '\\\\...' or sys.argv[-1] == '、、。。。':addhidegifpage = 1audacityflag = 1microvideo_flag = 1keeplastpage = 3sys.argv = sys.argv[:-1]
#------------------------------------------------------------
hideiddim = tspgethideid()
rect = tspgetviewdcrange()
tempdim = []
for id in hideiddim:infor = tspgetinfor(id)type = infor['type']if type == 11:ratio = infor['ratio']range1 = infor['range']width = int((range1[2]-range1[0])/ratio[0])height = int((range1[3]-range1[1])/ratio[1])if abs(width - rect[4]) < 10 and abs(height - rect[5]) < 10:tempdim.append(id)
hideiddim = tempdim
headpageid = 0
if len(hideiddim) == 0:hideiddim = getgifpic()
elif len(hideiddim) == 1:headpageid = hideiddim[0]hideiddim = getgifpic()if headpageid in hideiddim:headpageid = hideiddim.index(headpageid)else: headpageid = 0
#------------------------------------------------------------
leftwidth = 0
leftstring = ''
if len(sys.argv) > 1:idid = len(sys.argv) - 1id = sys.argv[idid].find('|')if id > 0:if sys.argv[idid][:id].isdigit():leftwidth = int(sys.argv[idid][:id])leftstring = sys.argv[idid][id+1:]elif sys.argv[idid] == 'ii' or sys.argv[idid] == 'i':leftwidth = 160leftstring = sys.argv[idid][id+1:].replace('》', '>')
cid = leftstring.find('C')
if cid < 0: cid = leftstring.find('c')
if cid >= 0:if leftstring[cid+1:].replace('-','').isdigit():headpageid = int(leftstring[cid+1:])leftstring = leftstring[:cid+1]
printf(leftstring, headpageid)
#------------------------------------------------------------
if leftstring.find('p') >= 0 or leftstring.find('P') >= 0 or leftstring.find('|') > 0 or\leftstring.find('#') >= 0 or leftstring.find('c') >= 0 or leftstring.find('C') >= 0:viewsize = tspgetviewsize()selid = tspgetselectid()flag = 0if len(selid) == 0 and len(hideiddim) > 0:selid = hideiddimfor id in selid:filename = tspgetdopfile(id)if isgifname(filename) == 0:flag = 1breakimagepastesize(filename, viewsize[0], viewsize[1], 1)leftstring = leftstring.replace('p','').replace('P','').replace('|','').replace('#','')if flag == 0 and len(selid) > 0:leftstring = leftstring + '_-%d'%len(selid)
if leftstring.find('R') >= 0 or leftstring.find('r') >= 0 or leftstring.find('\\') >= 0:viewsize = tspgetviewsize()selid = tspgetselectid()if len(selid) == 0 and len(hideiddim) > 0:selid = hideiddimflag = 0for id in selid:filename = tspgetdopfile(id)if isgifname(filename) == 0:flag = 1breakimageresize(filename, viewsize[0], viewsize[1])leftstring = leftstring.replace('*', '').replace('r','').replace('R','').replace('\\','')if flag == 0 and len(selid) > 0:leftstring = leftstring + '_-%d'%len(selid)
#------------------------------------------------------------
for s in sys.argv[1:]:filename = os.path.join(microvideo_dir, s+".MPG")if os.path.isfile(filename): strall.append(filename)filename = os.path.join(microvideo_dir, s+".AVI")if os.path.isfile(filename): strall.append(filename)filename = os.path.join(microvideo_mooc, s+".MPG")if os.path.isfile(filename): strall.append(filename)filename = os.path.join(microvideo_mooc, s+".AVI")if os.path.isfile(filename): strall.append(filename)
#------------------------------------------------------------
def avi2csdn(filename, newfile):#--------------------------------------------------------cam = cv2.VideoCapture(filename)ret, frame = cam.read()cv2.imwrite(r'd:\temp\1.bmp', frame)for _ in range(20):time.sleep(.25)printf('\a')if os.path.isfile(r'd:\temp\1.bmp'):breakimage = Image.open(r'd:\temp\1.bmp')output = BytesIO()image.convert('RGB').save(output, 'BMP')data = output.getvalue()[14:]output.close()send_to_clipboard(win32clipboard.CF_DIB, data)tspsendwindowkey(csdn_title, 'v', control=1)cam.release()for i in range(40):time.sleep(.5)readdata = tspread()if readdata[2] == 1: breakif readdata[7] != 0: breakif readdata[8] != 0: exit()if readdata[9] != 0: exit()tspsendwindowkey(csdn_title, 'c', control=1, noreturn=1)if clipboard.paste().find('在这里插入图片描述') >= 0:tspbeep(1500, 200)time.sleep(.25)breakprintf('\a')for i in range(20):readdata = tspread()if readdata[7] == 0 and readdata[8] == 0 and readdata[9] == 0: breaktspbeep(2500, 15)time.sleep(.25)tspsendwindowkey(csdn_title, 'ac', control=1, noreturn=1)pastestr = clipboard.paste().split('![在这里插入图片描述](')if len(pastestr) < 2:printf("Can not find the ![Insert picture] discriptor !\a")exit()tspsendwindowkey(csdn_title, 'z', control=1)pastestr = pastestr[1].split(')')[0]pastestr = pastestr.split('?')[0]insertstr = '![%s](%s#pic_center =%dx)'%(newfile, pastestr, picwidth)if leftwidth > 0:
#        insertstr = '![%s|%s](%s#pic_left =%dx) '%(newfile, leftstring, pastestr, leftwidth)if leftstring.find('c') < 0 and leftstring.find('C') < 0:insertstr = '![%s|%s](%s#pic_left =%dx) '%(filename, leftstring, pastestr, leftwidth)else:leftstring = leftstring.replace('c', '').replace('C', '')insertstr = '![%s|%s](%s#pic_center =%dx)\n\n'%(filename, leftstring, pastestr, leftwidth)clipboard.copy(insertstr)tspsendwindowkey(csdn_title, "v", control=1, noreturn=1)os.remove(r'd:\temp\1.bmp')
#------------------------------------------------------------
img_array = []
size = (100, 100)
mpegfile = []
avimove_flag = 0
copy_flag = 0                       # Save picture to temp\gif
#------------------------------------------------------------
picwidth = 350
if len(sys.argv) > 1:if sys.argv[1] == '**':microvideo_flag = 1if sys.argv[1] == '*':microvideo_flag = 1picwidth = 160if len(sys.argv) > 2:if sys.argv[2].isdigit():picwidth = int(sys.argv[2])argstr = ''.join(sys.argv[1:])if sys.argv[1] == '+' or argstr[:2] == '*+':microvideo_flag = 2if sys.argv[1] == '.' or argstr[:2] == '*.' or argstr[:2] == '*。':avimove_flag = 1microvideo_flag = 0if sys.argv[-1].isdigit():picwidth = int(sys.argv[-1])
if len(sys.argv) > 2:if sys.argv[2] == '\\' or sys.argv[2] == 'C' or sys.argv[2] == 'c':copy_flag = 1
#printf(sys.argv, avimove_flag)
#exit()
#------------------------------------------------------------
for f in strall:if os.path.isfile(f):microvideo_flag = 1picwidth = 160break
printf(microvideo_flag)
#------------------------------------------------------------
if microvideo_flag > 0:clipboard.copy("")gifiddim = tspgetgifid()seliddim = tspgetselectid()pictureflag = 0if len(gifiddim) == 0:if len(seliddim) > 0:gifiddim = seliddimpictureflag = 1if len(gifiddim) == 0:seliddim = hideiddimgifiddim = hideiddimpictureflag = 1if len(gifiddim) == 0:filecount = 0for s in strall:if os.path.isfile(s):filecount += 1if filecount == 0:printf('DOP has not GIF DOP .\a')exit()for s in strall:if os.path.isfile(s):ext = s.split('.')[-1].upper()if ext == 'MPG' or ext == 'AVI' or ext == 'MP4':avi2csdn(s, os.path.basename(s))exit()#------------------------------------------------------------outfile = numstrframeps = 20pagedim = []#------------------------------------------------------------if keeplastpage > 0 or audacityflag > 0:headbytes = b'\x55\xaa\x60\x06'databytes = int2short(-50)gifname = tspgetdopfile(gifiddim[0])tspimagesetstring(gifname, headbytes+databytes)#--------------------------------------------------------lastfilename = ''firstfilename = ''for gifid in gifiddim:if pictureflag > 0:filename = tspgetdopfile(gifid)lastfilename = filenameif len(firstfilename) == 0:firstfilename = filenameimg = cv2.imread(filename)mpegfile.append(filename)height,width,layers=img.shapesize = (width, height)img_array.append(img)continuefiledir = tspgetdoppath(gifid)gifpage = tspgetgifpage(gifid)filename = tspgetdopfile(gifid)nameonly, ext = os.path.splitext(filename)pagedim.append(gifpage)for i in range(gifpage):filename = os.path.join(filedir, '%04d%s'%(i, ext))lastfilename = filenameif len(firstfilename) == 0: firstfilename = filenameimg = cv2.imread(filename)mpegfile.append(filename)height,width,layers=img.shapesize = (width, height)img_array.append(img)#--------------------------------------------------------filename = '%s_%d_%d.MPG'%(outfile, width, height)gifdir = '%s_%d_%d'%(outfile, width, height)outfilename = os.path.join(microvideo_dir, filename)out = cv2.VideoWriter(outfilename, cv2.VideoWriter_fourcc(*'MPEG'), frameps, size, True)for id,img in enumerate(img_array):out.write(img)tspshowinfor('%d '%id)out.release()#--------------------------------------------------------keeplastfilename = ''if keeplastpage > 0:if os.path.isfile(lastfilename):numstr = int(time.time())keeplastfilename = r'd:\temp\BM%d.%s'%(numstr, lastfilename.split('.')[-1])shutil.copyfile(lastfilename, keeplastfilename)#--------------------------------------------------------if keeplastpage == 3:if os.path.isfile(firstfilename):changeimgrect(firstfilename)image = Image.open(firstfilename)output = BytesIO()image.convert('RGB').save(output, 'BMP')data = output.getvalue()[14:]output.close()send_to_clipboard(win32clipboard.CF_DIB, data)fname = os.path.basename(firstfilename)tspimagesetstring(0, fname)time.sleep(.2)clipboard.copy("")#--------------------------------------------------------if addhidegifpage > 0:#----------------------------------------------------fname = os.path.basename(outfilename)#----------------------------------------------------if os.path.isfile(firstfilename):changeimgrect(firstfilename)image = Image.open(firstfilename)output = BytesIO()image.convert('RGB').save(output, 'BMP')data = output.getvalue()[14:]output.close()send_to_clipboard(win32clipboard.CF_DIB, data)tspimagesetstring(0, fname)time.sleep(.2)clipboard.copy("")printf(fname)else:id = int(tspimagesetstring(0, fname))gifname = tspgetdopfile(id)tspimagesetstring(gifname, fname)#----------------------------------------------------if not os.path.isdir(r'd:\temp'):os.mkdir(r'd:\temp')if not os.path.isdir(r'd:\temp\GIF'):os.mkdir(r'd:\temp\GIF')gifcopydir = fname.split('.')[0]outgifdir = r'd:\temp\GIF\%s'%gifcopydirif not os.path.isdir(outgifdir):os.mkdir(outgifdir)for id,fn in enumerate(mpegfile):extstr = fn.split('.')[-1]outfile = os.path.join(outgifdir, '%04d.%s'%(id, extstr))shutil.move(fn, outfile)#----------------------------------------------------printf('\a')tspdeletedop(gifiddim)tsprv(-1)#----------------------------------------------------if audacityflag != 0:rect = tspgetwindowrect(AUDACITY_TITLE)if sum(rect) != 0:mp3file = outfilename.split('.')[0] + '.MP3'AudacitySave(mp3file)#----------------------------------------------------if keeplastpage > 0:if os.path.isfile(keeplastfilename):changeimgrect(keeplastfilename)tspacceptfile(keeplastfilename)os.remove(keeplastfilename)iddim = tspgetdopidall()if len(iddim) > 0:lastid = iddim[-1]infor = tspgetinfor(lastid)if 'type' in infor.keys():type = infor['type']if type == 11:ratio = infor['ratio']range1 = infor['range']width = int((range1[2]-range1[0])/ratio[0])height = int((range1[3]-range1[1])/ratio[1])rect = tspgetviewdcrange()if abs(width - rect[4]) < 10 and abs(height - rect[5]) < 10:setratio = (rect[2]-rect[0])/widthtspsetdopxy(lastid, rect[:4])tspsetresratio(lastid, int(setratio*100))tsprv(-3)if keeplastpage > 1:headbytes = b'\x55\xaa\x60\x06'databytes = int2short(1)id = int(tspimagesetstring(0, 15))gifname = tspgetdopfile(id)tspimagesetstring(gifname, headbytes+databytes)tsprv(-3)#----------------------------------------------------tsprv()tspfocuswindow('TEASOFT:1')exit()#--------------------------------------------------------if microvideo_flag == 2:clipboard.copy(filename + '\n')tspsendwindowkey(csdn_title, "v", control=1, noreturn=1)else:tspsendwindowkey(csdn_title,"c", control=1, noreturn=1)originstr = clipboard.paste()if len(originstr) > 0:tspsendwindowkey(csdn_title, " ")#----------------------------------------------------headfilename = mpegfile[0]printf(headpageid)if headpageid != 0:headfilename = mpegfile[headpageid]image = Image.open(headfilename)output = BytesIO()image.convert('RGB').save(output, 'BMP')data = output.getvalue()[14:]output.close()send_to_clipboard(win32clipboard.CF_DIB, data)tspsendwindowkey(csdn_title, 'v', control=1, noreturn=1)for i in range(40):time.sleep(.5)readdata = tspread()if readdata[2] == 1: breakif readdata[7] != 0: breakif readdata[8] != 0: exit()if readdata[9] != 0: exit()tspsendwindowkey(csdn_title, 'c', control=1, noreturn=1)if clipboard.paste().find('在这里插入图片描述') >= 0:tspbeep(1500, 200)time.sleep(.25)breakprintf('\a')for i in range(20):readdata = tspread()if readdata[7] == 0 and readdata[8] == 0 and readdata[9] == 0: breaktspbeep(2500, 15)time.sleep(.25)tspsendwindowkey(csdn_title, 'ac', control=1, noreturn=1)pastestr = clipboard.paste().split('![在这里插入图片描述](')if len(pastestr) < 2:printf("Can not find the ![Insert picture] discriptor !\a")exit()tspsendwindowkey(csdn_title, 'z', control=1)pastestr = pastestr[1].split(')')[0]pastestr = pastestr.split('?')[0]#----------------------------------------------------if pictureflag == 0 and leftwidth > 0:if len(pagedim) > 1:dimstr = '-'.join([str(n) for n in pagedim])leftstring = leftstring + '_=%s'%dimstr#----------------------------------------------------insertstr = '![%s](%s#pic_center =%dx)'%(filename, pastestr, picwidth)if leftwidth > 0:if leftstring.find('c') < 0 and leftstring.find('C') < 0:insertstr = '![%s|%s](%s#pic_left =%dx) '%(filename, leftstring, pastestr, leftwidth)else:leftstring = leftstring.replace('c', '').replace('C', '')insertstr = '![%s|%s](%s#pic_center =%dx)\n\n'%(filename, leftstring, pastestr, leftwidth)if len(originstr) > 0:clipboard.copy(insertstr+'\n'+originstr)else: clipboard.copy(insertstr)tspsendwindowkey(csdn_title, "v", control=1, noreturn=1)
#        printf(pastestr)clipboard.copy("")#--------------------------------------------------------if copy_flag > 0:if not os.path.isdir(r'd:\temp'):os.mkdir(r'd:\temp')if not os.path.isdir(r'd:\temp\GIF'):os.mkdir(r'd:\temp\GIF')outgifdir = r'd:\temp\GIF\%s'%gifdirif not os.path.isdir(outgifdir):os.mkdir(outgifdir)for id,fn in enumerate(mpegfile):extstr = fn.split('.')[-1]outfile = os.path.join(outgifdir, '%04d.%s'%(id, extstr))shutil.move(fn, outfile)else:for id,fn in enumerate(mpegfile):os.remove(fn)tspdeletedop(gifiddim)tsprv(-1)#----------------------------------------------------if audacityflag != 0:rect = tspgetwindowrect(AUDACITY_TITLE)if sum(rect) != 0:mp3file = outfilename.split('.')[0] + '.MP3'AudacitySave(mp3file)tspfocuswindow('TEASOFT:1')exit()
#------------------------------------------------------------
avifile = r'd:\temp\1.avi'
wavfile = r'd:\temp\1.wav'
mp3file = r'd:\temp\1.mp3'
mp4file = r'd:\temp\1.mp4'
avinumstr = 'AV%d'%(int(time.time()))
wavnumstr = 'WA%d'%(int(time.time()))
mp3numstr = 'MP%d'%(int(time.time()))
mp4numstr = "MP4%d"%(int(time.time()))
if avimove_flag > 0:for i in range(100):avifile = r'd:\temp\%d.avi'%(i+1)wavfile = r'd:\temp\%d.wav'%(i+1)mp3file = r'd:\temp\%d.mp3'%(i+1)mp4file = r'd:\temp\%d.mp4'%(i+1)flag = 0avinumstr = 'AV%d'%(int(time.time()))wavnumstr = 'WA%d'%(int(time.time()))mp3numstr = 'MP%d'%(int(time.time()))mp4numstr = "MP4%d"%(int(time.time()))if os.path.isfile(avifile):newfile = os.path.join(microvideo_dir, '%s.AVI'%avinumstr)shutil.copy(avifile, newfile)avi2csdn(avifile, '%s.AVI'%avinumstr)os.remove(avifile)printf("Copy file : %s"%avifile)flag += 1if os.path.isfile(wavfile):filename = '%s.WAV'%wavnumstrnewfile = os.path.join(microvideo_dir, filename)shutil.copy(wavfile, newfile)clipboard.copy("【%s】"%(filename))printf("Copy file : %s"%filename)tspsendwindowkey(csdn_title, "v", control=1, noreturn=1)os.remove(wavfile)flag += 1if os.path.isfile(mp3file):filename = '%s.MP3'%mp3numstrnewfile = os.path.join(microvideo_dir, filename)shutil.copy(mp3file, newfile)clipboard.copy("【%s】"%(filename))printf("Copy file : %s"%filename)tspsendwindowkey(csdn_title, "v", control=1, noreturn=1)os.remove(mp3file)flag += 1if os.path.isfile(mp4file):filename = '%s.MP4'%mp4numstrnewfile = os.path.join(microvideo_dir, filename)shutil.copy(mp4file, newfile)avi2csdn(mp4file, '%s.MP4'%mp4numstr)
#            clipboard.copy("【%s】"%(filename))
#            tspsendwindowkey(csdn_title, "v", control=1, noreturn=1)os.remove(mp4file)printf("Copy file : %s"%filename)flag += 1if flag > 0:time.sleep(1.0)printf('\a')else: breakprintf('\a')tspfocuswindow('TEASOFT:1')exit()
#------------------------------------------------------------
width = 480
height = 320
if len(sys.argv) == 7:filename, ext = os.path.splitext(sys.argv[1])filedir = os.path.dirname(sys.argv[1])gifpage = int(sys.argv[2])outfile = r'd:\temp\%s_%s_%s'%(sys.argv[5], sys.argv[3], sys.argv[4])framems = int(sys.argv[6])frameps = int(1000 / framems)printff(filedir, ext, outfile, gifpage, frameps)for i in range(gifpage):filename = os.path.join(filedir, '%04d%s'%(i, ext))img = cv2.imread(filename)mpegfile.append(filename)height,width,layers=img.shapesize = (width, height)img_array.append(img)
else:gifiddim = tspgetgifid()iddim = []if len(gifiddim) == 0:iddim = tspgetselectid()if len(iddim) == 0:iddim = hideiddimif len(iddim) == 0:printf('DOP has no GIF dop .\a')exit()#------------------------------------------------------------outfile = 'GM%d'%(int(time.time()))if len(sys.argv) > 1:if len(sys.argv[1]) > 0:outfile = sys.argv[1]frameps = 20if len(sys.argv) > 2:framems = int(sys.argv[2])frameps = int(1000 / framems)if len(iddim) > 0:for iidd in iddim:filename = tspgetdopfile(iidd)img = cv2.imread(filename)mpegfile.append(filename)height,width,layers=img.shapesize = (width, height)img_array.append(img)else:#-----------------------------------------------------for gifid in gifiddim:filedir = tspgetdoppath(gifid)gifpage = tspgetgifpage(gifid)filename = tspgetdopfile(gifid)nameonly, ext = os.path.splitext(filename)for i in range(gifpage):filename = os.path.join(filedir, '%04d%s'%(i, ext))img = cv2.imread(filename)mpegfile.append(filename)height,width,layers=img.shapesize = (width, height)img_array.append(img)
#------------------------------------------------------------
outfilename = r'd:\temp\%s_%d_%d.MPG'%(outfile, width, height)
if outfile.find(':') > 0:outfilename = r'%s.MPG'%(outfile)
out = cv2.VideoWriter(outfilename, cv2.VideoWriter_fourcc(*'MPEG'), frameps, size, True)
#------------------------------------------------------------
if not os.path.isdir(r'd:\temp'):os.mkdir(r'd:\temp')
if not os.path.isdir(r'd:\temp\GIF'):os.mkdir(r'd:\temp\GIF')
if not os.path.isdir(r'd:\temp\GIF\MPEG'):os.mkdir(r'd:\temp\GIF\MPEG')
mpegdir = r'd:\temp\GIF\MPEG'
mpegfiledim = os.listdir(mpegdir)
for f in mpegfiledim:os.remove(os.path.join(mpegdir, f))
#------------------------------------------------------------
#for i in range(gifpage):
#    out.write(img_array[i])
#    tspshowinfor('%d '%i)
for id,img in enumerate(img_array):out.write(img)tspshowinfor('%d '%id)newfile = os.path.join(mpegdir, os.path.basename(mpegfile[id]))
#    printf(newfile)shutil.copyfile(mpegfile[id], newfile)
out.release()
#------------------------------------------------------------
printf('\r\nAVI:%s\a'%outfilename)
printf('\a')
#------------------------------------------------------------
#        END OF FILE : GIF2MPG.PY
#============================================================

http://www.ppmy.cn/news/833556.html

相关文章

PCB制作中的过孔

在高速PCB 设计中&#xff0c;过孔设计是一个重要因素&#xff0c;它由孔、孔周围的焊盘区和POWER 层隔离区组成&#xff0c;通常分为盲孔、埋孔和通孔三类。在PCB 设计过程中通过对过孔的寄生电容和寄生电感分析&#xff0c;总结出高速PCB 过孔设计中的一些注意事项。 关键词&…

Altium AD20整板放置GND过孔、批量放置GND过孔/缝合孔

在PCB中大面放置GND过孔&#xff0c;可以有效减少回流路径&#xff0c;提高硬件稳定性。 提前将 Top Layer 和 Bottom Layer 铺铜。否则接下来整板放置GND过孔时&#xff0c;会提示错误&#xff1a;unable to locate any suitable locations on net gnd。 工具 - 缝合孔/屏蔽 …

如何造出39元的智能插座?——小米智能插座拆解

原文&#xff1a;http://www.leikeji.com/article?841 前些天雷科技做了一期小米智能插座的详细评测《便宜有好货 - 小米智能插座评测》&#xff0c;看到有网友在留言中表示质疑产品的内部构造情况&#xff0c;甚至有网友将智能插座和普通插座混为一谈。今天&#xff0c;雷科技…

AltiumDesigner设计PCB时如何挖孔开槽?

AltiumDesigner设计PCB时如何挖孔开槽&#xff1f; PCB挖孔开槽的作用具体操作 PCB挖孔开槽的作用 爬电 就是绝缘体表面沾污和受潮后绝缘电阻降低&#xff0c;在高压下产生电流&#xff08;乃至电弧&#xff09;的现象。 PCB虽然耐压也不低&#xff0c;但使用长久后会沾上灰尘和…

PCB散热过孔的设计

目前&#xff0c;越来越多的半导体功率器件为了减小体积&#xff0c;降低高度&#xff0c;都采用一些表贴封装&#xff0c;如QFN8*8,TOLL&#xff0c;TOLF等。这些表贴器件虽然热阻较传统的TO220&#xff0c;TO247封装小一点(不确定)&#xff0c;但其将如何将热量有效传导到机壳…

PCB贴片元器件手工焊接技巧及要点

转载--电子电路 2022-03-20 08:00 转载者语&#xff1a;在观看原作者文章过程中&#xff0c;结合自己工作中的经验&#xff0c;增加了些内容&#xff08;红色字&#xff09; ---炼丹师--小谭 内容简介 以下内容都是我最近焊贴片所收获的知识和技巧&#xff0c;现在无私分享给…

PCB封装孔小,元器件无法插入,如何解决?

DIP就是插件&#xff0c;采用这种封装方式的芯片有两排引脚&#xff0c;可以直接焊在有DIP结构的芯片插座上或焊在有相同焊孔数的焊位中。其特点是可以很方便地实现PCB板的穿孔焊接&#xff0c;和主板有很好的兼容性。但是由于其封装面积和厚度都比较大&#xff0c;而且引脚在插…

PADS(10)——添加过孔技巧

PADS在Layout和Router都可以打过孔&#xff0c; 一般在布线过程中用Router打过孔连接两根线&#xff0c; 而Layout一般是打一些顶底过孔用于连接两个层之间的铜皮。 设置过孔样式 无论是在Router中打过孔还是在Layout中打过孔都需要先在Layout中设置过孔样式。 1、点击设置–&g…