esp32c3 micropython oled實時天氣信息

目錄

簡介

效果展示

代碼

main.py

ssd1306.py

font.py

實現思路


簡介

合宙esp32c3 micropython框架,只支持128*64 I2C oled

ssd1306驅動我優化過的,與其他的不一樣,為避免出錯,使用我的驅動

把下面兩個py文件放入單片機內,

搜索心知天氣,注冊賬號,獲得免費的key

效果展示

代碼

main.py

import network
import urequests
from ssd1306 import SSD1306_I2C
from machine import Pin, I2C
import ujson
from font import textci2c = I2C(0, scl=Pin(5), sda=Pin(4))
oled = SSD1306_I2C(i2c)url = 'https://api.seniverse.com/v3/weather/now.json?key=你的密鑰&location=guangzhou&language=zh-Hans&unit=c'class Weather():def __init__(self, ssid, password):wifi=network.WLAN(network.STA_IF)wifi.active(True)#連接wifi,有一定幾率連接失敗while not wifi.isconnected():wifi.connect(ssid,password)oled.fill(0)oled.text('connecting...',0,0)oled.show()#更新顯示連接wifi信息   oled.fill(0)oled.text('connect to szsb',0,0)oled.show()response = urequests.get(url)parsed = ujson.loads(response.text)weather_info = parsed['results'][0]['now']temperature = weather_info['temperature']weather_state = weather_info['text']#下面兩條語句的作用是一樣的,二選一,把unicode編碼轉為中文字符# x=eval('u"%s"' % weather_state)x = ujson.loads('"%s"' % weather_state)oled.text(temperature + '`c', 80, 48)textc(oled, '廣', 80, 16)textc(oled, '州', 96, 16)oled.vline(60, 0, 64)if len(weather_state) == 2:textc(oled, x[0], 16, 48)textc(oled, x[1], 32, 48)if x[1] == '雨':if weather_state == '大雨':max_rainy = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0C, 0x10, 0x10, 0x08, 0x08, 0x10, 0x60, 0x80,0x80, 0x80,0x80, 0x60, 0x20, 0x10, 0x10, 0x08, 0x08, 0x06, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,0x00, 0x00,0x00, 0x00, 0x00, 0x60, 0x91, 0x8A, 0x09, 0x08, 0x08, 0x08, 0x08, 0x09, 0x0A, 0x09,0x08, 0x08,0x08, 0x08, 0x09, 0x0A, 0x09, 0x08, 0x08, 0x08, 0x08, 0x09, 0x92, 0x61, 0x00, 0x00,0x00, 0x00,0x00, 0x00, 0x00, 0xC0, 0x20, 0x20, 0x26, 0xC9, 0x11, 0x09, 0xC6, 0x20, 0x20, 0x26,0xC9, 0x11,0x09, 0xC6, 0x20, 0x20, 0x26, 0xC9, 0x11, 0x09, 0xC6, 0x20, 0x20, 0x20, 0xC0, 0x00,0x00, 0x00]oled.p32(max_rainy, 16, 8)elif weather_state == '中雨':mid_rainy = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,0x01, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x08, 0x08, 0x30, 0x40, 0x40, 0x80, 0x00, 0x00,0x00, 0x80,0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x30, 0x08, 0x08, 0x08, 0x06, 0x01, 0x01, 0x00,0x00, 0x00,0x00, 0x00, 0x60, 0x90, 0x11, 0x12, 0x14, 0x12, 0x11, 0x10, 0x10, 0x10, 0x11, 0x12,0x14, 0x12,0x11, 0x10, 0x10, 0x10, 0x11, 0x12, 0x14, 0x12, 0x11, 0x10, 0x10, 0x10, 0x20, 0xC0,0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x40, 0x40, 0x80, 0x00, 0x00, 0x00, 0x80, 0x40,0x40, 0x40,0x80, 0x00, 0x00, 0x00, 0x80, 0x40, 0x40, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00]oled.p32(mid_rainy, 16, 8)elif weather_state == '小雨':min_rainy = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,0x01, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x08, 0x08, 0x30, 0x40, 0x40, 0x80, 0x00, 0x00,0x00, 0x80,0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x30, 0x08, 0x08, 0x08, 0x06, 0x01, 0x01, 0x00,0x00, 0x00,0x00, 0x00, 0x60, 0x90, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x11, 0x12,0x14, 0x12,0x11, 0x10, 0x10, 0x10, 0x11, 0x12, 0x14, 0x12, 0x11, 0x10, 0x10, 0x10, 0x20, 0xC0,0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40,0x40, 0x40,0x80, 0x00, 0x00, 0x00, 0x80, 0x40, 0x40, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00]oled(min_rainy, 16, 8)else:cloud = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06,0x03, 0x01, 0x00, 0x00, 0x00, 0x0C, 0x06, 0x02, 0x00, 0x00, 0x0E, 0x0E, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8C, 0xC4, 0x44, 0x00, 0x00,0x00, 0x7F, 0x40, 0x40, 0x40, 0x47, 0x47, 0x40, 0x40, 0x40, 0x7F, 0x00, 0x23, 0x63, 0xC3, 0x00,0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x07, 0x1F, 0x3F, 0x3F, 0x3F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF,0x7F, 0xFF, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x1F, 0x07, 0x07, 0xFF, 0x00, 0x30, 0x18, 0x08, 0x00,0x00, 0x00, 0x00, 0xE0, 0xF0, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8,0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF0, 0xE0, 0x00, 0x00, 0x00, 0x00]oled.p32(cloud, 16, 8)else:textc(oled, x, 24, 48)if x == '晴':sunny = [0x00, 0x00, 0x00, 0x18, 0x1C, 0x0E, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8,0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x0E, 0x1C, 0x18, 0x00, 0x00, 0x00,0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x3F, 0x40, 0x80, 0x80, 0x80, 0x80, 0x83, 0x83,0x83, 0x83, 0x80, 0x80, 0x80, 0x80, 0x40, 0x3F, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01,0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0xFC, 0x02, 0x01, 0x01, 0x01, 0x01, 0xC1, 0xC1,0xC1, 0xC1, 0x01, 0x01, 0x01, 0x01, 0x02, 0xFC, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80,0x00, 0x00, 0x00, 0x18, 0x38, 0x70, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F,0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0x70, 0x38, 0x18, 0x00, 0x00, 0x00]oled.p32(sunny, 16, 8)elif x == '陰':shadow = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00,0x00, 0x00, 0x01, 0x03, 0x0F, 0x1F, 0x1F, 0x3F, 0x3F, 0x7F, 0x7F, 0x3F, 0x3F, 0x1F, 0x1F,0x0F,0x0F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x03, 0x01, 0x00,0x00,0x18, 0x7C, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,0xFF,0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0x7C,0x18,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00]oled.p32(shadow, 16, 8)oled.show()w = Weather('szsb', '55555555')

ssd1306.py

import framebuf
# 寄存器定義
SET_CONTRAST        = const(0x81)
SET_ENTIRE_ON       = const(0xa4)
SET_NORM_INV        = const(0xa6)
SET_MEM_ADDR        = const(0x20)
SET_COL_ADDR        = const(0x21)
SET_PAGE_ADDR       = const(0x22)
SET_DISP_START_LINE = const(0x40)
SET_DISP            = const(0xae)
SET_SEG_REMAP       = const(0xa0)
SET_MUX_RATIO       = const(0xa8)
SET_COM_OUT_DIR     = const(0xc0)
SET_DISP_OFFSET     = const(0xd3)
SET_COM_PIN_CFG     = const(0xda)
SET_DISP_CLK_DIV    = const(0xd5)
SET_PRECHARGE       = const(0xd9)
SET_VCOM_DESEL      = const(0xdb)
SET_CHARGE_PUMP     = const(0x8d)class SSD1306:def __init__(self,external_vcc):self.width = 128self.height = 64self.external_vcc = external_vccself.pages = 8self.init_display()def init_display(self):for cmd in (SET_DISP | 0x00, #熄屏SET_MEM_ADDR, 0x00, #水平尋址SET_DISP_START_LINE | 0x00,#顯示起始行地址SET_SEG_REMAP | 0x01, # column addr 127 mapped to SEG0SET_MUX_RATIO, 63,SET_COM_OUT_DIR | 0x08, # scan from COM[N] to COM0SET_DISP_OFFSET, 0x00,SET_COM_PIN_CFG, 0x12,# timing and driving schemeSET_DISP_CLK_DIV, 0x80,SET_PRECHARGE, 0x22 if self.external_vcc else 0xf1,SET_VCOM_DESEL, 0x30, # 0.83*Vcc# displaySET_CONTRAST, 0xff, # maximumSET_ENTIRE_ON, # output follows RAM contentsSET_NORM_INV, # not inverted# charge pumpSET_CHARGE_PUMP, 0x10 if self.external_vcc else 0x14,0x2e, # 禁止滾動0xae | 0x01): #開屏self.write_cmd(cmd)self.fill(0)self.show()def v_scroll(self, d=1): self.write_cmd(0x2e) # 關閉滾動if d:self.write_cmd(0x26) # 向左self.write_cmd(0x00)self.write_cmd(0x07) # 起始頁self.write_cmd(0x00) # 滾動幀率self.write_cmd(0x00) # 結束頁else:self.write_cmd(0x27) # 向左self.write_cmd(0x00)self.write_cmd(0x00) # 起始頁self.write_cmd(0x00) # 滾動幀率self.write_cmd(0x07) # 結束頁self.write_cmd(0x00)self.write_cmd(0xff)self.write_cmd(0x2f) # 開啟滾動def poweroff(self):self.write_cmd(const(0xae) | 0x00)#熄屏def contrast(self, contrast):self.write_cmd(SET_CONTRAST)self.write_cmd(contrast)def invert(self, invert):self.write_cmd(SET_NORM_INV | (invert & 1))def show(self):self.write_cmd(SET_COL_ADDR)self.write_cmd(0)self.write_cmd(127)self.write_cmd(SET_PAGE_ADDR)self.write_cmd(0)self.write_cmd(63)self.write_framebuf()def fill(self, c):self.framebuf.fill(c)def pixel(self, x, y, c):self.framebuf.pixel(x, y, c)def text(self, string, x, y, c=1):self.framebuf.text(string, x, y, c)def hline(self,x,y,w,c=1):self.framebuf.hline(x,y,w,c)def vline(self,x,y,h,c=1):self.framebuf.vline(x,y,h,c)def line(self,x1,y1,x2,y2,c=1):self.framebuf.line(x1,y1,x2,y2,c)def rect(self,x,y,w,h,c=1,f=False):self.framebuf.rect(x,y,w,h,c,f)def ellipse(self,x,y,xr,yr,c,f=False,m=15):self.framebuf.ellipse(x,y,xr,yr,c,f,m)def cube(self,x,y,l):self.rect(x,y,l,l)self.rect(x+int(0.5*l),int(y-0.5*l),l,l)self.line(x,y,int(x+0.5*l),int(y-0.5*l),1)self.line(x+l,y,int(x+1.5*l),int(y-0.5*l),1)self.line(x,y+l,int(x+0.5*l),int(y+0.5*l),1)self.line(x+l,y+l,int(x+1.5*l),int(y+0.5*l),1)def p8(self,page,x,y):for e in range(8):byte=bin(page[e]).replace('0b','')while len(byte)<8:byte='0'+bytefor i in range(8):if byte[i]=='1':self.pixel(x+e,y+i,int(byte[i]))def p16(self,page,x,y):for e in range(32):byte=bin(page[e]).replace('0b','')while len(byte)<8:byte='0'+bytefor i in range(8):if byte[i] and e<16:self.pixel(x+e,y+i,int(byte[i]))elif byte[i] and e>=16:self.pixel(x-16+e,y+8+i,int(byte[i]))def p32(self,page,x,y):for e in range(128):byte=bin(page[e]).replace('0b','')while len(byte)<8:byte='0'+bytefor i in range(8):if byte[i] and e<32:self.pixel(x+e,y+i,int(byte[i]))elif byte[i] and 32<=e<64:self.pixel(x+e-32,y+8+i,int(byte[i]))elif byte[i] and 64<=e<96:self.pixel(x+e-64,y+16+i,int(byte[i]))elif byte[i] and 96<=e<128:self.pixel(x+e-96,y+24+i,int(byte[i]))class SSD1306_I2C(SSD1306):def __init__(self,i2c, addr=0x3c, external_vcc=False):self.i2c = i2cself.addr = addrself.temp = bytearray(2)# buffer需要8 * 128的顯示字節加1字節命令self.buffer = bytearray(8 * 128 + 1)self.buffer[0] = 0x40  # Co=0, D/C=1self.framebuf = framebuf.FrameBuffer1(memoryview(self.buffer)[1:], 128, 64)super().__init__(external_vcc)def write_cmd(self, cmd):self.temp[0] = 0x80 # Co=1, D/C#=0self.temp[1] = cmdself.i2c.writeto(self.addr, self.temp)def write_framebuf(self):self.i2c.writeto(self.addr, self.buffer)

font.py

def u6674(oled,x,y):     oled.rect(x+1,y+2,4,11)oled.hline(x+2,y+7,2)oled.hline(x+6,y+2,9)oled.hline(x+7,y+4,7)oled.hline(x+6,y+6,9)oled.vline(x+10,y,7)oled.rect(x+7,y+8,7,8)oled.rect(x+7,y+10,7,3)oled.hline(x+8,y+15,4,0)
def u591a(oled,x,y):def duo1(x,y):oled.line(x+3,y+4,x+7,y)oled.hline(x+6,y+2,6)oled.line(x+4,y+3,x+6,y+5)oled.line(x+11,y+2,x+4,y+9)duo1(x,y)x+=3y+=6duo1(x,y)
def u9634(oled,x,y):oled.hline(x+2,y+1,11)oled.hline(x,y+6,15)oled.line(x+7,y+7,x+1,y+13)oled.hline(x+2,y+13,10)oled.line(x+9,y+10,x+13,y+14)
def u4e91(oled,x,y):oled.rect(x+2,y+4,11,7)oled.vline(x+7,y,16)
def u5927(oled,x,y):oled.hline(x+1,y+5,14)oled.vline(x+7,y+1,9)oled.line(x+6,y+10,x+1,y+15)oled.line(x+8,y+10,x+13,y+15)oled.pixel(x+14,y+15,1)
def u5c0f(oled,x,y):oled.vline(x+7,y+1,13)oled.line(x+5,y+6,x+1,y+10)oled.line(x+9,y+4,x+13,y+8)oled.line(x+6,y+14,x+5,y+13)
def u96e8(oled,x,y):oled.hline(x+1,y+1,14)oled.vline(x+7,y+2,13)oled.rect(x+1,y+5,13,11)oled.hline(x+2,y+15,9,0)oled.line(x+4,y+8,x+5,y+9)oled.line(x+4,y+11,x+5,y+12)oled.line(x+9,y+8,x+10,y+9)oled.line(x+9,y+11,x+10,y+12)
def u9634(oled,x,y):oled.vline(x+1,y+1,15)oled.hline(x+2,y+1,4)oled.line(x+5,y+2,x+2,y+5)oled.line(x+5,y+8,x+2,y+5)oled.hline(x+2,y+9,4)oled.vline(x+7,y+1,12)oled.line(x+6,y+12,x+4,y+15)oled.hline(x+8,y+1,5)oled.vline(x+13,y+1,14)oled.line(x+12,y+15,x+11,y+14)oled.rect(x+7,y+5,7,4)
def u5e7f(oled,x,y):oled.line(x+7,y+1,x+8,y+2)oled.line(x+1,y+14,x,y+15)oled.hline(x+2,y+3,12)oled.vline(x+2,y+4,10)
def u5dde(oled,x,y):oled.vline(x+1,y+5,3)oled.vline(x+3,y+1,12)oled.vline(x+6,y+5,3)oled.vline(x+8,y+2,12)oled.vline(x+10,y+5,3)oled.vline(x+12,y+1,14)oled.line(x+2,y+13,x+1,y+14)
def u4e0a(oled,x,y):oled.vline(x+6,y+1,14)oled.hline(x+7,y+6,6)oled.hline(x+1,y+14,14)
def u6d77(oled,x,y):oled.line(x+2,y+1,x+3,y+2)oled.line(x+1,y+5,x+2,y+6)oled.line(x+2,y+13,x+4,y+11)oled.line(x+9,y,x+5,y+4)oled.hline(x+7,y+2,7)oled.rect(x+7,y+4,6,9,1,True)oled.hline(x+5,y+8,10)oled.rect(x+8,y+5,4,3,0)oled.rect(x+8,y+9,4,3,0)oled.pixel(x+13,y+12,1)oled.vline(x+12,y+13,2)
#該字典存儲著一些中文的函數指針
cc_dict={'6674':u6674,'591a':u591a,'u9634':u9634,'4e91':u4e91,'5927':u5927,'u5c0f':u5c0f,'96e8':u96e8,'9634':u9634,'5e7f':u5e7f,'5dde':u5dde,'4e0a':u4e0a,'6d77':u6d77}
#顯示中文的函數,接受oled對象,要顯示的中文,位置
def textc(oled,c,x,y):c=hex(ord(c)).replace('0x','')cc_dict[c](oled,x,y)

實現思路

從網站獲取天氣數據,根據文本的字典結構,為了方便,轉成json進行有效信息的提取。

獲取的天氣狀態一共有小雨,中雨,大雨,陰,晴,多云

按照天氣狀態分為兩組,兩個字的和一個字的

設置了一個查找樹,對兩個字的進行快速查找,優化if結構

如果選擇好了天氣狀態,就在特定位置顯示中文(16*16)和天氣狀態對應的圖(32*32)

剩下的就是顯示城市和溫度了

我的代碼默認是廣州,你也可以更改其他城市

在font.py中,我以筆畫的方式存儲了天氣狀態對應的中文,還有‘廣州’對應的中文,相當于自己建立了一個小字庫,當然也可以更改為其他方式顯示中文,如取模,燒寫特殊固件

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/43342.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/43342.shtml
英文地址,請注明出處:http://en.pswp.cn/news/43342.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

SqlServer的with(nolock)關鍵字的用法介紹

舉個例子 下面就來演示這個情況。 為了演示兩個事務死鎖的情況&#xff0c;我們下面的測試都需要在SQL Server Management Studio中打開兩個查詢窗口。保證事務不被干擾。 --1、 沒有提交的事務&#xff0c;NOLOCK 和 READPAST處理的策略&#xff1a; --查詢窗口一請執行如下…

【馬蹄集】第二十三周——進位制專題

進位制專題 目錄 MT2186 二進制&#xff1f;不同&#xff01;MT2187 excel的煩惱MT2188 單條件和MT2189 三進制計算機1MT2190 三進制計算機2 MT2186 二進制&#xff1f;不同&#xff01; 難度&#xff1a;黃金 ?? 時間限制&#xff1a;1秒 ?? 占用內存&#xff1a;128M 題目…

Kotlin的Map

在 Kotlin 中&#xff0c;Map 是一種鍵值對的集合數據結構&#xff0c;用于存儲一組關聯的鍵和值。Kotlin 標準庫提供了 Map 接口和多種實現類&#xff0c;使得操作和處理鍵值對數據更加方便。下面詳細描述 Kotlin 的 Map 的用法&#xff1a; 創建 Map Kotlin 提供了幾種方式…

SQL力扣練習(十一)

目錄 1.樹節點(608) 示例 1 解法一(case when) 解法二(not in) 2.判斷三角形(610) 示例 1 解法一(case when) 解法二(if) 解法三(嵌套if) 3.只出現一次的最大數字(619) 示例 1 解法一(count limit) 解法二(max) 4.有趣的電影(620) 解法一 5.換座位(626) 示例 …

同步jenkinsfile流水線(sync-job)

環境 變量&#xff1a;env&#xff08;環境變量&#xff1a;sit/dev/simulation/prod/all&#xff09;&#xff0c;job&#xff08;job-name/all&#xff09;目錄&#xff1a;/var/lib/jenkins/jenkinsfile environment.json&#xff1a; [roottest-01 jenkinsfile]# cat env…

C++ string類的模擬實現

模擬實現string類不是為了造一個更好的輪子&#xff0c;而是更加理解string類&#xff0c;從而來掌握string類的使用 string類的接口設計繁多&#xff0c;故而不會全部涵蓋到&#xff0c;但是核心的會模擬實現 庫中string類是封裝在std的命名空間中的&#xff0c;所以在模擬…

webpack5和webpack4的一些區別

自動清除打包目錄 webpack4 // bash npm i clean-webpack-plugin -D //webpack.config.js const {CleanWebpackPlugin} require(clean-webpack-plugin); module.exports {plugins: [new CleanWebpackPlugin()} } webpack5 module.exports {output: {clean: true} } topLevel…

使用PostgreSQL構建強大的Web應用程序:最佳實踐和建議

PostgreSQL是一個功能強大的開源關系型數據庫,它擁有廣泛的用戶群和活躍的開發社區。越來越多的Web應用選擇PostgreSQL作為數據庫 backend。如何充分利用PostgreSQL的特性來構建健壯、高性能的Web應用?本文將給出一些最佳實踐和建議。 一、選擇合適的PostgreSQL數據類型 Pos…

【Vue】Mixin 混入

Vue Mixin 混入 1.簡介 混入&#xff08;mixin&#xff09;提供了一種非常靈活的方式&#xff0c;來分發 Vue 組件中的可復用功能。一個混入對象可以包含任意組件選項&#xff08;如data、methods、mounted等等&#xff09;。當組件使用混入對象時&#xff0c;所有混入對象的…

Java將時間戳轉化為特定時區的日期字符串

先上代碼&#xff1a; ZonedDateTime dateTime ZonedDateTime.ofInstant(Instant.ofEpochMilli(System.currentTimeMillis()),zone ); //2019-12-01T19:01:4608:00String formattedDate dateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd") ); //2019-12-…

.git內存清理方式

查看前15個大文件 git rev-list --objects --all | grep "$(git verify-pack -v .git/objects/pack/*.idx | sort -k 3 -n | tail -15 | awk {print$1})"刪除文件夾&#xff08;public/housimg文件夾目錄&#xff09; git filter-branch --tree-filter rm -rf publ…

解決使用element ui時el-input的屬性type=number,仍然可以輸入e的問題。

使用element ui時el-input的屬性typenumber&#xff0c;仍然可以輸入e&#xff0c; 其他的中文特殊字符都不可以輸入&#xff0c;但是只有e是可以輸入的&#xff0c;原因是e也輸入作為科學計數法的時候&#xff0c;e是可以被判定為數字的&#xff0c; 但是有些場景是需要把e這種…

DICOM圖像的常用一些參數解析

醫學圖像DICOM醫學影像文件格式詳解 Dicom文件基本操作 DICOM圖像參數&#xff1f; 像素&#xff1a;構成圖片的小色點。圖像每個維度的像素個數——該維度一共有多少個均勻分布的像素點。 分辨率&#xff08;單位DPI&#xff09;&#xff1a;每英寸&#xff08;Inch&#xf…

鴻蒙剝離 AOSP 不兼容 Android 熱門問題匯總,不吹不黑不吵

上周發了一篇 《鴻蒙終于不套殼了&#xff1f;純血 HarmonyOS NEXT 即將到來》的相關資訊&#xff0c;沒想到大家「討&#xff08;fa&#xff09;論&#xff08;xie&#xff09;」的熱情很高&#xff0c;莫名蹭了一波流量&#xff0c;雖然流量對我來說也沒什么用&#xff0c;但…

私密數據采集:隧道爬蟲IP技術的保密性能力探究

作為一名專業的爬蟲程序員&#xff0c;今天要和大家分享一個關鍵的技術&#xff0c;它能夠為私密數據采集提供保密性能力——隧道爬蟲IP技術。如果你在進行敏感數據采集任務時需要保護數據的私密性&#xff0c;那么這項技術將是你的守護神。 在進行私密數據采集任務時&#xff…

不了解UI設計需要掌握的技能? 優漫動游

很多人聽說過UI設計行業&#xff0c;知道它是用來制作界面的高薪技術&#xff0c;但對于做UI設計需要什么技能卻不是很清楚。且看本文的分析。? 不了解UI設計需要掌握的技能&#xff1f; ??UI設計是英文User和interface的縮寫&#xff0c;是指對軟件的人機交互、操作邏輯、界…

Java基礎知識題(二)

系列文章目錄 Java基礎知識題(一) 文章目錄 系列文章目錄 前言 1. Java中的 組合、聚合和關聯有什么區別&#xff1f; 2. 解釋為什么Java被稱作是“平臺無關的編程語言”&#xff1f; 3. 簡述什么是值傳遞和引用傳遞&#xff1f;重點 4. 詳細闡述Java進程和線程的區別 …

Java # JVM

一、1.8之前 運行時數據區&#xff08;進程共享&#xff09; 運行時常量池為什么要有方法區&#xff1a; jvm完成類裝載后&#xff0c;需要將class文件中的常量池轉入內存&#xff0c;保存在方法區中為什么是常量&#xff1a; 常量對象操作較多&#xff0c;為了避免頻繁創建和…

圖像去雨-雨線清除-圖像處理-(計算機作業附代碼)

背景 多年來&#xff0c;圖像去雨已經被廣泛研究&#xff0c;使用傳統方法和基于學習的方法。然而&#xff0c;傳統方法如高斯混合模型和字典學習方法耗時&#xff0c;并且無法很好地處理受到嚴重雨滴影響的圖像塊。 算法 通過考慮雨滴條狀特性和角度分布&#xff0c;這個問…