主頁 > 作業系統 > 按下按鈕或輸入時如何在輸入中呼叫事件

按下按鈕或輸入時如何在輸入中呼叫事件

2022-03-22 20:15:37 作業系統

我目前正在撰寫一個數學程式。它具有啟動,然后顯示數學問題,直到您正確回答10,然后停止的功能。它有效,但用戶只能在按下按鈕 ( confirm()) 時確認他們的答案。這真的很煩人。我想讓它在用戶enter在輸入欄位中按下時也會激活。

如果用戶在游標位于輸入欄位內時按下回車,如何呼叫事件?

# GUI
import sys
import tkinter as tk
import tkinter.ttk as ttk
from tkinter.constants import *

import gui2temp3_support

class spiel:
    def __init__(self, top=None):
        '''This class configures and populates the toplevel window.
           top is the toplevel containing window.'''
        _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
        _fgcolor = '#000000'  # X11 color: 'black'
        _compcolor = '#d9d9d9' # X11 color: 'gray85'
        _ana1color = '#d9d9d9' # X11 color: 'gray85'
        _ana2color = '#ececec' # Closest X11 color: 'gray92'
        self.style = ttk.Style()
        if sys.platform == "win32":
            self.style.theme_use('winnative')
        self.style.configure('.',background=_bgcolor)
        self.style.configure('.',foreground=_fgcolor)
        self.style.map('.',background=
            [('selected', _compcolor), ('active',_ana2color)])

        top.geometry("600x450 475 21")
        top.minsize(600, 450)
        top.maxsize(600, 450)
        top.resizable(0,0)
        top.title("Mathe-Skill-Programm Aktiv")
        top.configure(background="#d9d9d9")
        top.configure(highlightbackground="#d9d9d9")
        top.configure(highlightcolor="black")
        top.bind('<Button-1><Button-1>',lambda e:gui2temp3_support.spiel(e))

        self.top = top

        self.Appname = tk.Label(self.top)
        self.Appname.place(relx=0.0, rely=0.0, height=51, width=604)
        self.Appname.configure(activebackground="#f9f9f9")
        self.Appname.configure(activeforeground="black")
        self.Appname.configure(background="#008080")
        self.Appname.configure(compound='left')
        self.Appname.configure(disabledforeground="#a3a3a3")
        self.Appname.configure(font="-family {Bahnschrift Light} -size 24 -weight bold")
        self.Appname.configure(foreground="#ffffff")
        self.Appname.configure(highlightbackground="#008080")
        self.Appname.configure(highlightcolor="black")
        self.Appname.configure(text='''Valentin's Lernprogramm''')

        self.Frame1 = tk.Frame(self.top)
        self.Frame1.place(relx=0.017, rely=0.133, relheight=0.856
                , relwidth=0.975)
        self.Frame1.configure(relief='groove')
        self.Frame1.configure(borderwidth="2")
        self.Frame1.configure(relief="groove")
        self.Frame1.configure(background="#d9d9d9")
        self.Frame1.configure(highlightbackground="#d9d9d9")
        self.Frame1.configure(highlightcolor="black")

        self.confirm = tk.Button(self.Frame1)
        self.confirm.place(relx=0.034, rely=0.26, height=44, width=197)
        self.confirm.configure(activebackground="#ececec")
        self.confirm.configure(activeforeground="#000000")
        self.confirm.configure(background="#008080")
        self.confirm.configure(command=gui2temp3_support.speichern)
        self.confirm.configure(compound='left')
        self.confirm.configure(disabledforeground="#a3a3a3")
        self.confirm.configure(font="-family {Segoe UI} -size 9 -weight bold")
        self.confirm.configure(foreground="#ffffff")
        self.confirm.configure(highlightbackground="#d9d9d9")
        self.confirm.configure(highlightcolor="black")
        self.confirm.configure(pady="0")
        self.confirm.configure(text='''Antwort best?tigen''')
        self.confirm.bind('<Button-1>',lambda e:gui2temp3_support.confirm(e))

        self.results = tk.LabelFrame(self.Frame1)
        self.results.place(relx=0.017, rely=0.39, relheight=0.584
                , relwidth=0.957)
        self.results.configure(relief='groove')
        self.results.configure(font="-family {Segoe UI} -size 9 -weight bold")
        self.results.configure(foreground="black")
        self.results.configure(text='''Resultate''')
        self.results.configure(background="#d9d9d9")
        self.results.configure(highlightbackground="#d9d9d9")
        self.results.configure(highlightcolor="black")

        self.zeit = tk.Label(self.results)
        self.zeit.place(relx=0.018, rely=0.133, height=21, width=284
                , bordermode='ignore')
        self.zeit.configure(activebackground="#f9f9f9")
        self.zeit.configure(activeforeground="black")
        self.zeit.configure(anchor='w')
        self.zeit.configure(background="#d9d9d9")
        self.zeit.configure(compound='left')
        self.zeit.configure(disabledforeground="#a3a3a3")
        self.zeit.configure(font="-family {Segoe UI} -size 9 -weight bold")
        self.zeit.configure(foreground="#000000")
        self.zeit.configure(highlightbackground="#d9d9d9")
        self.zeit.configure(highlightcolor="black")
        self.zeit.configure(text='''Zeit ben?tigt:''')

        self.score = tk.Label(self.results)
        self.score.place(relx=0.018, rely=0.222, height=21, width=244
                , bordermode='ignore')
        self.score.configure(activebackground="#f9f9f9")
        self.score.configure(activeforeground="black")
        self.score.configure(anchor='w')
        self.score.configure(background="#d9d9d9")
        self.score.configure(compound='left')
        self.score.configure(disabledforeground="#a3a3a3")
        self.score.configure(font="-family {Segoe UI} -size 9 -weight bold")
        self.score.configure(foreground="#000000")
        self.score.configure(highlightbackground="#d9d9d9")
        self.score.configure(highlightcolor="black")
        self.score.configure(text='''Score:''')

        self.nachricht = tk.Label(self.results)
        self.nachricht.place(relx=0.018, rely=0.8, height=21, width=534
                , bordermode='ignore')
        self.nachricht.configure(activebackground="#f9f9f9")
        self.nachricht.configure(activeforeground="black")
        self.nachricht.configure(anchor='w')
        self.nachricht.configure(background="#d9d9d9")
        self.nachricht.configure(compound='left')
        self.nachricht.configure(disabledforeground="#a3a3a3")
        self.nachricht.configure(font="-family {Segoe UI} -size 9 -weight bold")
        self.nachricht.configure(foreground="#000000")
        self.nachricht.configure(highlightbackground="#d9d9d9")
        self.nachricht.configure(highlightcolor="black")
        self.nachricht.configure(text= "Hallo, Lieber Benutzer!")

        self.temp_score = tk.Label(self.results)
        self.temp_score.place(relx=0.018, rely=0.311, height=21, width=244
                , bordermode='ignore')
        self.temp_score.configure(activebackground="#f9f9f9")
        self.temp_score.configure(activeforeground="black")
        self.temp_score.configure(anchor='w')
        self.temp_score.configure(background="#d9d9d9")
        self.temp_score.configure(compound='left')
        self.temp_score.configure(disabledforeground="#a3a3a3")
        self.temp_score.configure(font="-family {Segoe UI} -size 9 -weight bold")
        self.temp_score.configure(foreground="#000000")
        self.temp_score.configure(highlightbackground="#d9d9d9")
        self.temp_score.configure(highlightcolor="black")
        self.temp_score.configure(text='''Punkte:''')

        self.multiplier = tk.Label(self.results)
        self.multiplier.place(relx=0.018, rely=0.4, height=21, width=244
                , bordermode='ignore')
        self.multiplier.configure(activebackground="#f9f9f9")
        self.multiplier.configure(activeforeground="black")
        self.multiplier.configure(anchor='w')
        self.multiplier.configure(background="#d9d9d9")
        self.multiplier.configure(compound='left')
        self.multiplier.configure(disabledforeground="#a3a3a3")
        self.multiplier.configure(font="-family {Segoe UI} -size 9 -weight bold")
        self.multiplier.configure(foreground="#000000")
        self.multiplier.configure(highlightbackground="#d9d9d9")
        self.multiplier.configure(highlightcolor="black")
        self.multiplier.configure(text='''Multiplier:''')

        self.richtige_ant = tk.Label(self.results)
        self.richtige_ant.place(relx=0.018, rely=0.489, height=21, width=244
                , bordermode='ignore')
        self.richtige_ant.configure(activebackground="#f9f9f9")
        self.richtige_ant.configure(activeforeground="black")
        self.richtige_ant.configure(anchor='w')
        self.richtige_ant.configure(background="#d9d9d9")
        self.richtige_ant.configure(compound='left')
        self.richtige_ant.configure(disabledforeground="#a3a3a3")
        self.richtige_ant.configure(font="-family {Segoe UI} -size 9 -weight bold")
        self.richtige_ant.configure(foreground="#000000")
        self.richtige_ant.configure(highlightbackground="#d9d9d9")
        self.richtige_ant.configure(highlightcolor="black")
        self.richtige_ant.configure(text='''''')

        self.deine_ant = tk.Label(self.results)
        self.deine_ant.place(relx=0.018, rely=0.578, height=21, width=244
                , bordermode='ignore')
        self.deine_ant.configure(activebackground="#f9f9f9")
        self.deine_ant.configure(activeforeground="black")
        self.deine_ant.configure(anchor='w')
        self.deine_ant.configure(background="#d9d9d9")
        self.deine_ant.configure(compound='left')
        self.deine_ant.configure(disabledforeground="#a3a3a3")
        self.deine_ant.configure(font="-family {Segoe UI} -size 9 -weight bold")
        self.deine_ant.configure(foreground="#000000")
        self.deine_ant.configure(highlightbackground="#d9d9d9")
        self.deine_ant.configure(highlightcolor="black")
        self.deine_ant.configure(text='''''')

        self.xy = tk.Label(self.Frame1)
        self.xy.place(relx=0.034, rely=0.052, height=41, width=154)
        self.xy.configure(activebackground="#f9f9f9")
        self.xy.configure(activeforeground="black")
        self.xy.configure(anchor='w')
        self.xy.configure(background="#d9d9d9")
        self.xy.configure(compound='left')
        self.xy.configure(disabledforeground="#a3a3a3")
        self.xy.configure(font="-family {Segoe UI} -size 21 -weight bold")
        self.xy.configure(foreground="#000000")
        self.xy.configure(highlightbackground="#d9d9d9")
        self.xy.configure(highlightcolor="black")
        self.xy.configure(text='''x * y =''')

        self.antwort = tk.Entry(self.Frame1)
        self.antwort.place(relx=0.308, rely=0.052, height=50, relwidth=0.297)
        self.antwort.configure(background="white")
        self.antwort.configure(disabledforeground="#a3a3a3")
        self.antwort.configure(font="-family {Segoe UI} -size 21 -weight bold")
        self.antwort.configure(foreground="#000000")
        self.antwort.configure(highlightbackground="#d9d9d9")
        self.antwort.configure(highlightcolor="black")
        self.antwort.configure(insertbackground="black")
        self.antwort.configure(selectbackground="blue")
        self.antwort.configure(selectforeground="white")

        self.start_stop = tk.Button(self.Frame1)
        self.start_stop.place(relx=0.393, rely=0.26, height=44, width=197)
        self.start_stop.configure(activebackground="#ececec")
        self.start_stop.configure(activeforeground="#000000")
        self.start_stop.configure(background="#fc6d71")
        self.start_stop.configure(command=gui2temp3_support.speichern)
        self.start_stop.configure(compound='left')
        self.start_stop.configure(disabledforeground="#a3a3a3")
        self.start_stop.configure(font="-family {Segoe UI} -size 9 -weight bold")
        self.start_stop.configure(foreground="#ffffff")
        self.start_stop.configure(highlightbackground="#d9d9d9")
        self.start_stop.configure(highlightcolor="black")
        self.start_stop.configure(pady="0")
        self.start_stop.configure(text='''Start''')
        self.start_stop.bind('<Button-1>',lambda e:gui2temp3_support.start_stop(e))

        self.progress = ttk.Progressbar(self.Frame1)
        self.progress.place(relx=0.786, rely=0.052, relwidth=0.188, relheight=0.0
                , height=22)
        self.progress.configure(length="110")

        self.quit = tk.Button(self.Frame1)
        self.quit.place(relx=0.752, rely=0.26, height=44, width=117)
        self.quit.configure(activebackground="#ececec")
        self.quit.configure(activeforeground="#000000")
        self.quit.configure(background="#c10438")
        #self.quit.configure(command=gui2temp3_support.speichern)
        self.quit.configure(compound='left')
        self.quit.configure(disabledforeground="#a3a3a3")
        self.quit.configure(font="-family {Segoe UI} -size 9 -weight bold")
        self.quit.configure(foreground="#ffffff")
        self.quit.configure(highlightbackground="#d9d9d9")
        self.quit.configure(highlightcolor="black")
        self.quit.configure(pady="0")
        self.quit.configure(text='''Verlassen''')
        self.quit.bind('<Button-1>',lambda e:gui2temp3_support.quit(e))


def start_up():
    gui2temp3_support.main()

if __name__ == '__main__':
    gui2temp3_support.main()


支持模塊:

import sys
import tkinter as tk
import tkinter.ttk as ttk
from tkinter.constants import *
import time
import gui2temp3
from random import randint, choice

hex = ["1","2","3","4","5","6","7","8","9","0","A","B","C","D","E","F"]
nachrichtenfalsch = ['HAHAHA! DU VERLIERER! DEINE ANTWORT WAR KOMPLETT FALSCH HAHAHAA!', 'LOSER!!!', '0 IQ LOL', 'VERKACKT!', 'FALSCHE ANTWORT HAHAHHAA', '-99999999999999 SOCIAL CREDIT', 'MATHE GEHT BEI DIR WOHL NICHT, NE?', 'Deine Antwort war nicht richtig. Aber du musst jetzt nicht traurig sein, denn so etwas kann jedem mal passieren. Du bist immer noch so besonders fuer uns wie du es immer gewesen bist! Komm schon, vergiss den Zwischenfall und geb nicht auf!', '1x1 Zertifikat entzogen', 'NOOOOOOOB!', 'Du kannst besser fliegen als Matheaufgaben zu beantworten.', 'Mathematik scheint dir wohl nicht so zu liegen, LOL', 'Du kleiner Discord Mod, kannst noch nicht mal Matheaufgaben richtig beantworten.', 'Du dummer FETTSACK HAHAHA', 'INKORREKTE EINGABE HAHAHAA', 'irrefuehrende Rueckaeusserung einer primitiven Lebensform.', 'Du hast die Frage komplett Falsch beantwortet. Deswegen nehme ich dir jetzt einen Keks weg. HAHAHAHA']
nachrichtengut = ['Verdammt richtig man!', 'So was von korrekt!', 'Weiter so!', 'Deine Antwort war richtig!', 'SUPER!!!', 'Deine Antwort war richtig! Als Belohnung bekommst du einen Keks :)', 'DU BIST EIN GENIE!!', '101% Korrekt!', 'Richtig wie ein Glas mit Nutella!', 'Sie werden es noch einmal ganz weit bringen!', 'Als ich so alt war wie du haette ich das nie gekonnt!', 'Du kleines Wunderkind!']
death = 3
gestartet = False
time_start = time.time()
time1 = ""
correct_answer = ""
xmin = 2
xmax = 11
ymin = 1
ymax = 15
temp_start = None
c_answers = 0
w_answers = 0
s_answers = 0
score = 0
temp_score = 1
multiplier = 1
totaltime = 0
timestart = 0
timeend = 0
time_stop = 0
temp_end = None
fulltime = 0
temp_answers = 1
averangetime = 0
lowest_time = 0
worst_time = 0
time_wasted_total = 0
user_answer = ""

def main(*args):
    '''Main entry point for the application.'''
    global root
    root = tk.Tk()
    root.protocol( 'WM_DELETE_WINDOW' , root.destroy)
    # Creates a toplevel widget.
    global _top2, _w2
    _top2 = root
    _w2 = gui2temp3.spiel(_top2)
    root.mainloop()

def confirm(*args):
    global user_answer
    if gestartet is True:
        user_answer = _w2.antwort.get()
        _w2.nachricht.configure(foreground="#000000")
        _w2.antwort.delete(0, END)

        if str.isdecimal(user_answer) is False or user_answer == "":
            _w2.nachricht.configure(foreground="#FF0000")
            _w2.nachricht.configure(text="DU BIST EIN IDIOT!!! GIB ZAHLEN EIN, OK?!?!?")
        elif int(user_answer) == correct_answer:
            c_response()
            update()

        else:
            w_response()
    else:
        _w2.nachricht.configure(foreground="#FF0000")
        _w2.nachricht.configure(text="DU BIST EIN IDIOT!!! DAS PROGRAMM IS NOCH NICHTMAL GESTARTET!!")


def c_response():
    global totaltime, temp_score, lowest_time, worst_time, c_answers, temp_answers, score, multiplier, temp_end
    _w2.deine_ant.configure(text="")
    _w2.richtige_ant.configure(text="")
    _w2.nachricht.configure(text=choice(nachrichtengut))
    temp_end = time.time()
    c_answers  = 1
    temp_answers  = 1
    multiplier = 0.9   (0.1 * temp_answers)
    totaltime = temp_end - temp_start
    temp_score = round(multiplier / totaltime * 1000, 1)
    score  = temp_score
    _w2.temp_score.configure(text=f"Punkte:  {temp_score}")
    _w2.score.configure(text=f"Score: {score}")
    _w2.zeit.configure(text=f"Zeit ben?tigt: {round(totaltime,2)} Sekunden")
    _w2.multiplier.configure(text=f"Multiplier: {multiplier}")
    _w2.progress['value']  = 10
    if totaltime <= lowest_time:
        lowest_time = totaltime
        _w2.nachricht.configure(text=f"{choice(nachrichtengut)} (BESTZEIT!!)")
    elif lowest_time == 0:
        lowest_time = totaltime

    if totaltime >= worst_time:
        worst_time = totaltime
    if _w2.progress['value'] >= 100:
        start_stop()

def w_response():
    global totaltime, temp_score, time_wasted_total, w_answers, multiplier, temp_answers, user_answer
    w_answers  = 1
    temp_end = time.time()
    totaltime = temp_end - temp_start

    temp_answers = 1
    multiplier = 0.9   (0.1 * temp_answers)
    temp_score -= round(1000 * w_answers, 1)
    _w2.nachricht.configure(text=choice(nachrichtenfalsch))
    _w2.temp_score.configure(text=f"Punkte: {temp_score}")
    _w2.score.configure(text=f"Score: {score}")
    _w2.zeit.configure(text=f"Zeit verschwendet: {round(totaltime,2)} Sekunden")
    _w2.multiplier.configure(text=f"Multiplier: {multiplier}")
    _w2.richtige_ant.configure(text=f"Richtige Antwort: {correct_answer}")
    _w2.deine_ant.configure(text=f"Deine dumme Antwort: {user_answer}")

    temp_score = 0
def quit(*args):
    root.destroy()

def speichern(*args):
    return

def spiel(*args):
    print('gui2temp3_support.spiel')
    for arg in args:
        print ('another arg:', arg)
    sys.stdout.flush()
def update():
    global temp_start, correct_answer
    temp_start = time.time()
    x = randint(int(xmin), int(xmax))
    y = randint(int(ymin), int(ymax))
    _w2.xy.configure(text=f'''{x} * {y} =''')
    correct_answer = x * y
def start_stop(*args):
    global gestartet, correct_answer, temp_start, temp_end, time_stop
    if gestartet is False:
        _w2.start_stop.configure(text='''Stop''')
        _w2.start_stop.configure(background="#ffffff")
        _w2.start_stop.configure(foreground="#fc6d71")
        gestartet = True
        temp_start = time.time()
        update()

    elif gestartet is True:
        _w2.start_stop.configure(text='''Start''')
        _w2.start_stop.configure(background="#fc6d71")
        _w2.start_stop.configure(foreground="#ffffff")
        time_stop = time.time()
        gestartet = False
        zeit_antwort = time_stop - time_start
        _w2.xy.configure(text=f'''x * y =''')
        _w2.zeit.configure(text=f'''Zeit Gesamt: {round(zeit_antwort, 2)} Sekunden''')
        temp_start = 0
        temp_end = 0
        _w2.progress['value'] = 0
    elif _w2.progress['value'] >= 100:
        _w2.start_stop.configure(text='''Neustarten''')
        _w2.start_stop.configure(background="#fc6d71")
        _w2.start_stop.configure(foreground="#ffffff")
        time_stop = time.time()
        gestartet = False
        end_config()

def end_config():
        global time_start, time_stop
        zeit_antwort = time_stop - time_start
        _w2.xy.configure(text=f'''x * y =''')
        _w2.zeit.configure(text=f'''Zeit Gesamt: {round(zeit_antwort, 2)} Sekunden''')
        _w2.richtige_ant.configure(text=f"Richtige Antworten: {c_answers}")
        _w2.deine_ant.configure(text=f"Falsche Antworten: {w_answers}")

        _w2.multiplier.configure(text=f"Durchschnittszeit pro richtige Antwort: {round(zeit_antwort / c_answers, 2)}")


if __name__ == '__main__':
    gui2temp3.start_up()




uj5u.com熱心網友回復:

您將事件系結到相關的小部件。在下面的示例中,'<Return>'是有問題的鍵,并且return_pressed是按下該鍵時觸發的函式或方法的名稱。

有關更多詳細資訊,請參閱此內容。

旁注:您可能還想閱讀bind_all

        self.antwort.bind('<Return>', return_pressed)

轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/446469.html

標籤:Python python-3.x tkinter

上一篇:TkinterListboxSelect回呼總是處理串列中的最后一項

下一篇:在運行時在tkinter中添加和更新新小部件

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • CA和證書

    1、在 CentOS7 中使用 gpg 創建 RSA 非對稱密鑰對 gpg --gen-key #Centos上生成公鑰/密鑰對(存放在家目錄.gnupg/) 2、將 CentOS7 匯出的公鑰,拷貝到 CentOS8 中,在 CentOS8 中使用 CentOS7 的公鑰加密一個檔案 gpg -a ......

    uj5u.com 2020-09-10 00:09:53 more
  • Kubernetes K8S之資源控制器Job和CronJob詳解

    Kubernetes的資源控制器Job和CronJob詳解與示例 ......

    uj5u.com 2020-09-10 00:10:45 more
  • VMware下安裝CentOS

    VMware下安裝CentOS 一、軟硬體準備 1 Centos鏡像準備 1.1 CentOS鏡像下載地址 下載地址 1.2 CentOS鏡像下載程序 點擊下載地址進入如下圖的網站,選擇需要下載的版本,這里選擇的是Centos8,點擊如圖所示。 決定選擇Centos8后,選擇想要的鏡像源進行下載,此 ......

    uj5u.com 2020-09-10 00:12:10 more
  • 如何使用Grep命令查找多個字串

    如何使用Grep 命令查找多個字串 大家好,我是良許! 今天向大家介紹一個非常有用的技巧,那就是使用 grep 命令查找多個字串。 簡單介紹一下,grep 命令可以理解為是一個功能強大的命令列工具,可以用它在一個或多個輸入檔案中搜索與正則運算式相匹配的文本,然后再將每個匹配的文本用標準輸出的格式 ......

    uj5u.com 2020-09-10 00:12:28 more
  • git配置http代理

    git配置http代理 經常遇到克隆 github 慢的問題,這里記錄一下幾種配置 git 代理的方法,解決 clone github 過慢。 目錄 git配置代理 git單獨配置github代理 git配置全域代理 配置終端環境變數 git配置代理 主要使用 git config 命令 git單獨 ......

    uj5u.com 2020-09-10 00:12:33 more
  • Linux npm install 裝包時提示Error EACCES permission denied解

    npm install 裝包時提示Error EACCES permission denied解決辦法 ......

    uj5u.com 2020-09-10 00:12:53 more
  • Centos 7下安裝nginx,使用yum install nginx,提示沒有可用的軟體包

    Centos 7下安裝nginx,使用yum install nginx,提示沒有可用的軟體包。 18 (flaskApi) [root@67 flaskDemo]# yum -y install nginx 19 已加載插件:fastestmirror, langpacks 20 Loading ......

    uj5u.com 2020-09-10 00:13:13 more
  • Linux查看服務器暴力破解ssh IP

    在公網的服務器上經常遇到別人爆破你服務器的22埠,用來挖礦或者干其他嘿嘿嘿的事情~ 這種情況下正確的做法是: 修改默認ssh的22埠 使用設定密鑰登錄或者白名單ip登錄 建議服務器密碼為復雜密碼 創建普通用戶登錄服務器(root權限過大) 建立堡壘機,實作統一管理服務器 統計爆破IP [root ......

    uj5u.com 2020-09-10 00:13:17 more
  • CentOS 7系統常見快捷鍵操作方式

    Linux系統中一些常見的快捷方式,可有效提高操作效率,在某些時刻也能避免操作失誤帶來的問題。 ......

    uj5u.com 2020-09-10 00:13:31 more
  • CentOS 7作業系統目錄結構介紹

    作業系統存在著大量的資料檔案資訊,相應檔案資訊會存在于系統相應目錄中,為了更好的管理資料資訊,會將系統進行一些目錄規劃,不同目錄存放不同的資源。 ......

    uj5u.com 2020-09-10 00:13:35 more
最新发布
  • vim的常用命令

    Vim的6種基本模式 1. 普通模式在普通模式中,用的編輯器命令,比如移動游標,洗掉文本等等。這也是Vim啟動后的默認模式。這正好和許多新用戶期待的操作方式相反(大多數編輯器默認模式為插入模式)。 2. 插入模式在這個模式中,大多數按鍵都會向文本緩沖中插入文本。大多數新用戶希望文本編輯器編輯程序中一 ......

    uj5u.com 2023-04-20 08:43:21 more
  • vim的常用命令

    Vim的6種基本模式 1. 普通模式在普通模式中,用的編輯器命令,比如移動游標,洗掉文本等等。這也是Vim啟動后的默認模式。這正好和許多新用戶期待的操作方式相反(大多數編輯器默認模式為插入模式)。 2. 插入模式在這個模式中,大多數按鍵都會向文本緩沖中插入文本。大多數新用戶希望文本編輯器編輯程序中一 ......

    uj5u.com 2023-04-20 08:42:36 more
  • docker學習

    ###Docker概述 真實專案部署環境可能非常復雜,傳統發布專案一個只需要一個jar包,運行環境需要單獨部署。而通過Docker可將jar包和相關環境(如jdk,redis,Hadoop...)等打包到docker鏡像里,將鏡像發布到Docker倉庫,部署時下載發布的鏡像,直接運行發布的鏡像即可。 ......

    uj5u.com 2023-04-19 09:26:53 more
  • 設定Windows主機的瀏覽器為wls2的默認瀏覽器

    這里以Chrome為例。 1. 準備作業 wsl是可以使用Windows主機上安裝的exe程式,出于安全考慮,默認情況下改功能是無法使用。要使用的話,終端需要以管理員權限啟動。 我這里以Windows Terminal為例,介紹如何默認使用管理員權限打開終端,具體操作如下圖所示: 2. 操作 wsl ......

    uj5u.com 2023-04-19 09:25:49 more
  • docker學習

    ###Docker概述 真實專案部署環境可能非常復雜,傳統發布專案一個只需要一個jar包,運行環境需要單獨部署。而通過Docker可將jar包和相關環境(如jdk,redis,Hadoop...)等打包到docker鏡像里,將鏡像發布到Docker倉庫,部署時下載發布的鏡像,直接運行發布的鏡像即可。 ......

    uj5u.com 2023-04-19 09:19:04 more
  • Linux學習筆記

    IP地址和主機名 IP地址 ifconfig可以用來查詢本機的IP地址,如果不能使用,可以通過install net-tools安裝。 Centos系統下ens33表示主網卡;inet后表示IP地址;lo表示本地回環網卡; 127.0.0.1表示代指本機;0.0.0.0可以用于代指本機,同時在放行設 ......

    uj5u.com 2023-04-18 06:52:01 more
  • 解決linux系統的kdump服務無法啟動的問題

    問題:專案麒麟系統服務器的kdump服務無法啟動,沒有相關日志無法定位問題。 1、查看服務狀態是關閉的,重啟系統也無法啟動 systemctl status kdump 2、修改grub引數,修改“crashkernel”為“512M(有的機器數值太大太小都會導致報錯,建議從128M開始試,或者加個 ......

    uj5u.com 2023-04-12 09:59:50 more
  • 解決linux系統的kdump服務無法啟動的問題

    問題:專案麒麟系統服務器的kdump服務無法啟動,沒有相關日志無法定位問題。 1、查看服務狀態是關閉的,重啟系統也無法啟動 systemctl status kdump 2、修改grub引數,修改“crashkernel”為“512M(有的機器數值太大太小都會導致報錯,建議從128M開始試,或者加個 ......

    uj5u.com 2023-04-12 09:59:01 more
  • 你是不是暴露了?

    作者:袁首京 原創文章,轉載時請保留此宣告,并給出原文連接。 如果您是計算機相關從業人員,那么應該經歷不止一次網路安全專項檢查了,你肯定是收到過資訊系統技術檢測報告,要求你加強風險監測,確保你提供的系統服務堅實可靠了。 沒檢測到問題還好,檢測到問題的話,有些處理起來還是挺麻煩的,尤其是線上正在運行的 ......

    uj5u.com 2023-04-05 16:52:56 more
  • 細節拉滿,80 張圖帶你一步一步推演 slab 記憶體池的設計與實作

    1. 前文回顧 在之前的幾篇記憶體管理系列文章中,筆者帶大家從宏觀角度完整地梳理了一遍 Linux 記憶體分配的整個鏈路,本文的主題依然是記憶體分配,這一次我們會從微觀的角度來探秘一下 Linux 內核中用于零散小記憶體塊分配的記憶體池 —— slab 分配器。 在本小節中,筆者還是按照以往的風格先帶大家簡單 ......

    uj5u.com 2023-04-05 16:44:11 more