diff --git a/pythonProject/1.py b/pythonProject/1.py new file mode 100644 index 0000000..296f707 --- /dev/null +++ b/pythonProject/1.py @@ -0,0 +1,39 @@ +import tkinter as tk +import csv +import random + + +# 从CSV读取数据 +def read_words_from_csv(file_path): + with open(file_path, 'r', encoding='utf-8') as csvfile: + reader = csv.reader(csvfile) + next(reader) # 跳过表头 + return list(reader) + + +# 随机选取固定数量的单词 +def select_random_words(words, count=5): + return random.sample(words, count) + + +# 创建并显示单词 +def display_words(window, words): + for index, (number, word) in enumerate(words, start=1): + tk.Label(window, text=f"{number}: {word}", font=("Arial", 12)).pack(pady=5) + + +# 主程序 +def main(): + # 读取单词 + words = read_words_from_csv('words.csv') + + window = tk.Tk() + window.title("单词学习器") + + tk.Button(window, text="开始背单词", + command=lambda: display_words(tk.Toplevel(), select_random_words(words, 5))).pack(pady=10) + window.mainloop() + + +if __name__ == "__main__": + main() diff --git a/pythonProject/2.py b/pythonProject/2.py index d2ad0d8..c76a83d 100644 --- a/pythonProject/2.py +++ b/pythonProject/2.py @@ -1,37 +1,33 @@ # -*- coding: gbk -*- -from typing import List +import pymysql +import pandas as pd +# -*- coding: -*- -import mysql -import mysql.connector -import csv db_config = { 'host': 'localhost', + 'port': 3306, 'user': 'root', - 'password': '2141203017', + 'password': '21412030117', 'database': 'word', - + 'charset': 'utf8mb4', } -cnx = mysql.connector.connect(**db_config) -cursor = cnx.cursor() - -# ȡCSV -with open('extracted_data.csv', mode='r', encoding='utf-8') as file: - reader = csv.reader(file) - headers = next(reader, None) - if headers is not None: # ͷ - for row in reader: - sql = "INSERT IGNORE INTO word(xuhao,neirong) VALUES (%s, %s)" - cursor.execute(sql, (row[0], row[1])) #csvݿӦ try: - # ...ԭִд룩 - cnx.commit() - print("ݵɹ") -except mysql.connector.Error as err: - print(f"ݵʧ: {err}") -finally: - cursor.close() - cnx.close() + connection = pymysql.connect(**db_config) + cursor = connection.cursor() + extracted='data.csv' + data_to_insert= pd.read_csv(extracted) + + + for item in data_to_insert: + xuhao, neirong = item + insert_sql = "INSERT INTO word (xuhao, neirong) VALUES (%s, %s)" + cursor.execute(insert_sql, (xuhao, neirong)) + + connection.commit() + print("ݲɹ") +except Exception as e: + print(f"ݲʧܣϢ{e}") \ No newline at end of file diff --git a/pythonProject/extracted_data.csv b/pythonProject/extracted_data.csv deleted file mode 100644 index 83eb3d2..0000000 --- a/pythonProject/extracted_data.csv +++ /dev/null @@ -1,1201 +0,0 @@ -, -1,abandon vt.Ѯɪ -2,ability n.ͣը -3,abnormal a.賣䣻̬ -4,aboard ad.ڴ(ʫ)ϣϴ -5,abroad ad.()⣻ -6,absence n.ȱϯϹˣʫ̥ -7,absent a.ڳģȱ -8,abstract a. n.ժҪ -9,abundant a.ģʼ -10,abuse vt.ľˣŰ n.£ -11,access n.ӽͨԣǿ -12,accompany vt.ѩ飬Ʊޣ -13,accomplish vt.ɵ() -14,account n.ԬͣĿ -15,accuse vt.𣻹 -16,accustom vt.ϰ -17,accustomed a.߳ģϰе -18,achieve vt.Уʵ֣ -19,achievement n.ͣ -20,acquaintance n.ʶأ -21,act vi.γ𣻼 n.Ϊ -22,action n.жݣ -23,active a.Ծģ -24,activity n.Уж -25,actress n.Ƕط -26,actually ad.ƸԣȻ -27,acute a.ģؤ -28,add vt.ߣ裬 -29,addition n.ʣӷ -30,additional a.ļӵģ۵ -31,address n.ؼݺ̸ -32,adjust vt.У -33,administration n. -34,admire vt.׫Ľ -35,admission n.룻 -36,admit vt.ڣ̼ -37,advance vi.ǰ n.չ -38,advanced a.Ƚ -39,advantage n.ŵ㣬ƣ -40,adventure n.ðգչ -41,adult -42,advertisement n.棻Ƿܸ -43,advisable n.ǵģ -44,advise vt.棻ͨ -45,affect vt.죻꼬 -46,affection n.Ȱϣ -47,afford vt.𡭣ṩ -48,aggressive a.Եģö -49,agony n.ζԳ -50,agreement n.Э飻ͬ -51,agriculture n.ҵũѧ -52,aid n.ļȻ -53,airline -54,alphabet n.ϵͳ -55,alter vt.ƻգ룻 -56,alternative n.ȡᣬ -57,although conj.ԣ -58,altitude n.ߣߺˣߴ -59,altogether ad.ȫɽ -60,amaze vt.ʹ棬ʹ -61,ambition n.ͲҰ -62,ambitious -63,ambulance n.Ȼս¥Ժ -64,amplify vt.٣ǿ -65,amuse vt.ΨùԳ -66,angel n.ʹ -67,anger n.ŭ vt.۷ŭ -68,angle n.ǣ -69,ankle n.ף -70,annoy vt.ʹͼ -71,apart ad.ظֿ۲ -72,apartment n.Ԣ -73,appeal vi.&n.أ -74,appliance n.ߣߣе -75,applicable a.Ӧþߣĩڵ -76,application n.룻ʩ -77,apply vt.ãգʹ -78,appoint vt.Ͼçȷ -79,appointment n.綨 -80,appreciate vt.ͣ᣻л -81,approach vt.򡭿 n. -82,appropriate a.¦ҵģǡ -83,architecture n.έĽʽ -84,argument n.ۣ˦ģ -85,arise vi.ߺɡ -86,artificial a.ģ -87,artist n.ģɵ -88,artistic a.壻ʹ -89,aspect n.ѹӣ -90,assign vt.飻䣻ָ -91,assignment n.ָҵ -92,assist vt.Ԯí -93,assistant n.ӹƤ -94,associate vi. n.飬 -95,association n.Эᣬ壻Я -96,assure vt.ʹմ򡭱Ũ -97,astonish vt.ʹȣʹ -98,astronaut n.ͩԱٺԱ -99,Atlantic a. n. -100,attach vt.§ۣ -101,attack vt.&vi.&n.ף -102,attain vt.ﵽã -103,attempt vt.ԣͼ n.DZ -104,attract vt.Ŀ飬ջ -105,attraction n. -106,attractive a. -107,attribute vt.ä n.ֲ -108,audience n.ڣڣ -109,author n.죬 -110,authority n.֣ݷȨ -111,auto n.()˿ -112,automatic a.˪ѻӢ -113,automation n.ԶԶ -114,automobile n. -115,available a.Ѻ׻ԣŲ -116,awkward a.ģ -117,ban -118,bare -119,bargain n. vi.棻 -120,barrier n.ϣϰ -121,bear -122,belong vi.ñڣ -123,beneficial a.ģˢ -124,benefit n.棻 -125,billion num.Ǩ(Ӣ) -126,bind vt.󣻰ѿ -127,biology n.յѧ̬ѧ -128,bitter a.ʹ֧Ϻ -129,bloom n.ӣң -130,bold a.󵨵ģ׳ -131,bond n.ߣϵDZ -132,bother vt.ţԻ n.ӻ -133,brighten vt.ʹʹ⣻ʹ -134,brilliant a.Եģ׿Խ -135,boom -136,bull n.ȣ۲ -137,burden n.ӣװ -138,campaign n.սۣ˶ -139,cancer n.֢ -140,candidate n.ԺͶ -141,capable a.бͻģײŷ -142,capacity n.ӣӪ -143,capital n.ŵڣ -144,captain n.½ξ -145,captive n.²౳å -146,cargo n. -147,cartoon -148,carriage n.ͳ -149,carrier n.ɣص۱ -150,casual a.żɤ˫ -151,centimetre n.֣ -152,central a.ݵģʴ -153,century n.ͣٶ -154,channel n.ïε -155,character n.Ը񣻱ԣ -156,characteristic a.д n. -157,charming a.䰮 -158,chase n.ʷ׷£׷ -159,cheat vt.ƭࣻ vi.ƭ -160,cheater -161,childhood n.ͯ꣬ݩꣻ -162,childish a.ӵģص -163,chill vt.ʹ n. -164,china n. -165,Christian n.ܶͽ -166,Christmas n.ƽ -167,circumstance n.÷ -168,citizen n.ץ -169,civil a.ģְ -170,civilization n.Ĵ -171,civilize vt.˱ -172,clarify vt.굨 -173,cliff n.£߱ -174,climax -175,colleague n.ͬޣͬ -176,collective a.Ե -177,colony n.ֳȴ -178,combination n.ۣ -179,combine vt.ʹ˺ -180,community n.ѣ -181,commemorate v. -182,companion n.ͬ飻ըϣܻ -183,comparative a.ģԵ -184,compare vt.ȿգ -185,comparison n.ȵ -186,compete vi.ȵޣԿ -187,competent a.ԭܹģӦò -188,competition n.񣬱 -189,complain vi.֣𺮣ظ -190,complaint n.Թɴ̣ظ -191,compose vt.Ѣۣˣ -192,composition n.ɣ룻 -193,comprehension n.⣻ -194,comprehensive a.㷺ģ -195,compress vt.ѹ棬ѹ -196,compromise n.Э -197,compute vt.̣ԣ -198,concentrate vt.Уף -199,concentration n.϶רע -200,concept n.۳У -201,conclude vt.˼ɣ -202,conclusion n.ǿëۣβ -203,condemn vt.Ǵָа -204,conference n.ۻ -205,confess vt.ϣϵꣻ̹ -206,confine vt.ƣϿ -207,conform -208,congress n.ޣᣬ -209,conquer vt.޷սأƳ -210,conquest n.ȡ -211,consciousness n.ӳɣ֪ӯ -212,consent n.ͬ⣬й vi.ͬ -213,conservation n.棬㻤 -214,conservative a.ص n.Ⱦµ -215,consider vt.ϰѣǣ -216,considerable a.ģҪ -217,considerate a.׵ģԸ -218,consideration n.ǣ˼ԧ -219,constant a.ߺģõ -220,construct vt.죻裻 -221,construction n.죻磻 -222,contemporary a.ģͬʱ -223,contest vt.ڣռ -224,contribute vt.ףãͶ -225,convenience n. -226,convenient a.ģĤ -227,convention n.ϰ̰ϡԼ -228,conventional a.ģߵ -229,convince vt.ʹȷţʹŷ -230,count vt. vi. -231,counter n.񿡣 -232,county n.Ӣľ֣Ю -233,crash vi.ӣ n.ײ -234,creep vi.Уܵؽ -235,create -236,creation -237,creative -238,ceature -239,crisis n.ͽ֮ -240,cultivate vt.кֲ -241,culture n. -242,curse n.佡Ǵ -243,damage vt.𲵣ɻ n. -244,data n.ɧ; -245,declare vt.ԣѦ -246,decrease vi.&n.٣ -247,deepen vt. vi. -248,defeat vt.ʤ -249,defect n.ȱãȱ -250,define vt.ۡ¶䶨 -251,definite a.ȷϺ -252,definitely ad.һȷ -253,definition n.з -254,delicate a.˸ģ -255,delicious a.ȵң -256,delight n. vt.ʹ߱ -257,deliver vt.Ͷݣѯ -258,delivery n.Ͷݣ -259,demand vt.ģҪѯ -260,democracy n.Ĭ -261,democratic a.ҤԵ -262,demonstrate vt.˵֤ -263,deny vt.񶨣ܾ -264,depart vi.̣߷ -265,department n.࣬˾ͯ -266,departure n. -267,depend vi.򣻴 -268,dependent a.޸ȱ -269,deposit vt. -270,depress vt.ʹ -271,depth n.հȣޣȴ -272,derive vt.ȡ vi. -273,descend vi.պʳ -274,describe vt.ݣд -275,description n.ݣ -276,deserve vt.ܣֵ -277,desirable a.ڵúբģȡ -278,desire vt.¥Ǩ n.Ը -279,despair n. vi. -280,desperate a.üģ -281,despise vt.Ϣ -282,destruction n.ƻ -283,device n.еã -284,devil n.Ů -285,devote vt. -286,dictate vt.&vi.ڣ -287,dictation n.̬¼д -288,dictionary n.ãϵ -289,differ vi.ͬ -290,difference n.𣻲ָ -291,different a.ģֵ -292,diploma -293,diplomatic -294,disable vt.ܣʹ˲ -295,disadvantage n.غ -296,disagree vi.·磻һ -297,disappear vi.ʧ -298,disappoint vt.ʹʧʹܴ -299,disaster n.ѣֻ -300,discard vt.ų -301,discharge vt.߷ţ n. -302,discipline n.еʭ vt. -303,disclose vt.ҷ¶ -304,discourage vt.ʹйʹ -305,discover vt.֣¶ѭ -306,discovery n.ֵ֣µ -307,disease n.٣ŷ -308,dishonour n.ʣƣ -309,dismiss vt.ٿ˧ -310,disorder n.ңȥңɧ -311,display vt.УЩ -312,disposal n.ܣѣ -313,dispose vi.ӧģĤ -314,disposable -315,displease vt.ʹ죬ʹ -316,dissolve vt.ܽ⣻ɢ -317,distance n.ϥ꣬伵Զ -318,distant a.ҵģԶ -319,distinct a.öͬ -320,distinction n.𣬲䣬 -321,distinguish vt.ݷᣬϱ -322,distress n.ǣˣ -323,distribute vt.˼ͣ -324,distribution n.䣻಼ -325,diverse a.һ࣬ -326,divide vt.֣ƥ䣻ֿ -327,division n.֣£ -328,divorce n. vi. -329,domestic a.ģ׮ͥ -330,dorm n. -331,dormitory n.ܻң -332,dose n.Ψһ -333,downpour -334,drunk a.ģճ -335,drown -336,durable a.;õģ -337,duration n. -338,eager a.ļӦ -339,earn vt.̦ã -340,earnest a.ģ -341,earthquake n.𣻴 -342,ease n.ģ vt. -343,echo n.س vi.ظ -344,economic a.õģѧ -345,economical a.DzԼϣͼ˯ -346,economy n.гسԣʡ -347,elaborate a.ң׳ -348,elect vt.ѡȫѡ -349,election n.ǣȨѡ -350,electric a.ݣ -351,electrical a.ɼƵ -352,electricity n.磬ѧ -353,electron n. -354,electronic a.ӵ -355,electronics n.׵ѧ -356,element n.֣ҪԪɥ -357,elementary a.ƣ -358,eliminate vt. -359,elimination n.ſ -360,embarrass vt.ʹۣԹΪ -361,embrace vt. -362,emerge vi.ӿ֣찴 -363,emergency n.ͻ־ -364,employee -365,enable -366,enclose vt.Χסзꣻ -367,encounter vt. n. -368,encourage vt.֣㳤 -369,endure vt.գ -370,enemy n.ã룻б -371,enforce vt.ʵʩУǿ -372,engage vt.ʹ½Ƹ -373,engine n.ݶƣ棻 -374,engineer n.֫ʦʦ -375,engineering n.̣ѧ -376,enlarge vt.ףչ¸ -377,enormous a.޴ģӴ -378,ensure vt.֤ -379,entertain vt.ʹ֣д -380,entitle vt.(Ǧ) -381,entrance n.޿ڣ棻Թ -382,environment n.磻 -383,evaluate vt.ۣļ -384,evaporate vt.ʹ vi.£ -385,eve n.ҹԽڣǰһ -386,eventually ad.ֲ -387,evil n.а񣻳ƺ a. -388,evolution n.껯 -389,evolve vt.ʹʹ -390,exaggerate vt.&vi.书Ǧ -391,examination n.ԣ켼ϸ -392,examine vt.կϣϸ۲ -393,example n.ӣʵⷶ -394,exceed vt. -395,exceedingly ad.dz -396,excellent a.ģӨԵ -397,except prep.֮ -398,exception n.⣬ -399,excess n.ʣϹ -400,excessive a.ۼȵ -401,exchange vt. n.滻 -402,excite vt.ʹܣ -403,exciting a.˷ܸ -404,exclaim vi. -405,exclude vt.աų -406,exclusively ad.ű -407,excuse vt.£ﰸ n.Ͽ -408,execute vt. -409,executive a.ִе n.н -410,exercise n.ѵ vi.ϰ -411,exhaust vt.ʹƣǾþ -412,exhibit vt.ʾУչ -413,exhibition n.չУչ -414,existence n.˸ڣʵڣ -415,expand vt.Ө -416,expansion n. -417,expect vt.׺ϣڣȴ -418,expectation n. -419,expense n.ѣѣ -420,expensive a.Ĺģ¶ -421,expert n.ޱ a. -422,explain vt.ͣѽ -423,explanation n.Ⱨ˵ -424,export vt. -425,expose vt.ʹ¶¶ -426,exposure n.¶Ʈ -427,express vt. n.쳵Ҫ -428,expression n.ױꣻ -429,extend vt.ܽ -430,extension n.ӷDz֣ -431,extensive a.ϣº -432,extent n.ȣ壻̶ -433,exterior a.չ -434,external a.ģ⻡ -435,extraordinary a.ǵѰģַ -436,extreme a.ȸƣͷ -437,extremely ad.䣬 -438,eyesight n.Ӿ -439,facility n.豸ӣϣպ -440,faculty n.ͣݣϵ߶ -441,fade vi.ʵݽʧ -442,failure n.ʧͰʧܵ -443,faith n.㣬ŷȣ -444,faithful a.ҳϵģʵ -445,fame n.˦ -446,familiar a.첰ģ -447,famine n.óģ˳ -448,famous a.ģ˥޵ -449,fancy n.ˣ᣻ -450,fare n.ѣѣý -451,fashionable a.үʱ -452,fatal a.ģӵ -453,favour n.øУ޽ȣĻ -454,favourable a.ܵģϲ -455,favourite a.˿ϲ -456,federal a.ģ˵ -457,fee n.ʣͿ -458,feed vt.ι() vi.̼ -459,feedback n.ؽӦ -460,fellow n.֤Ҿϰ -461,female n.ƷŮ -462,fierce a.ţ -463,figure n.֣£ -464,fill vt.װʢվռ -465,final a.ΣƮԵ -466,finally ad.½ӵ -467,finance n.ʲգԴ -468,financial a.ѡģڵ -469,finding n.֣Ľ -470,fine a.õģ̶ģ -471,finger n.ָָ״ -472,fisherman n.ķױ -473,flavour n.ζζ -474,flee -475,flesh n.⣬˹ -476,flourish vi.٣ïΣ˶ -477,flow vi.Ʈdz -478,flu n.Ըð -479,fluent a.ģص -480,fluid n.壬 -481,focus vi.۽ע n. -482,fond a.޷ģ -483,forecast n.Ԥ⣬Ԥ vt.Ԥ -484,forehead n.ͷ첿 -485,foremost a.ϣһ -486,form n.η¸ vt.γ -487,formal a.ȼµģϵ -488,formation n.ڻгɣγɹ -489,former a.ǰ n. -490,fortnight n.ͣʮ -491,fortune n.׵צŲ -492,fountain n.ˮȪԴ -493,freedom n.ɴԶ -494,frontier n. -495,fulfil vt.У㣻 -496,further ad.ݱ a.Զ -497,furthermore ad.Ѻѿפ -498,gain vt.ã n.Ħ -499,gap n.ȱڣɻ -500,gasoline n.() -501,general a.ܵģµn. -502,generally ad.һӵأͨĶ -503,generate vt.𣻹 -504,generation n.һ߶һֽ -505,generator n. -506,generous a.𣻼 -507,genius n.ţ츳 -508,gentle a.ȵģ -509,gentleman n.ʿн -510,gently ad.ò -511,genuine a.̼Ц -512,geography n.Ǻѧ -513,geometry n.Σ -514,germ n.΢ϸѿ -515,gloomy a.ǽģѻ -516,glorious a.ٵģ׳۶ -517,goodness n.ԣʷ -518,goods n.߻ -519,govern vt.Σ£Ʊ -520,government n. -521,governor n.פ˹˵ -522,grace n.׺ɹ -523,graceful a.ģŵ -524,gracious a.ܸ -525,grade vt.⡭ȼ n.ȼ -526,grain n. -527,grateful a.¶ģ컣 -528,gratitude a.󣬸 -529,greenhouse n.ʹ˶ů -530,guard vt.ĥ n.ݱ -531,guidance n.ص鵼 -532,guide n. vt.ʭ -533,guilty a.ξεģ -534,handle n. vt.ң -535,handwriting n.û -536,harden vt.ʹĤ vi. -537,hardship n.ѣȻ -538,hardware n.ߣë -539,harmony n.ϣ¢г -540,hatred n.գޣ -541,heal vt.ʹ -542,health n.ܽ濵״ -543,healthy a.ģ -544,heir n.ã -545,hesitate vi.ԥֺ -546,hire vt. n.壬 -547,hijack -548,historical a.ʷ̹ͣʷ -549,hopeless a.ûгģ -550,hostile a.ģ -551,household n.ͥЫ -552,humble a.ǫѷߣ¼ -553,humorous a.Ĭģڶг -554,humour n.ĬԡȣĬ -555,hunt n.˨ԣѰ vt.ʦ -556,ice-cream n.Ż -557,ideal a.գģ -558,ignorant a.أ֪ -559,ignore vt.ˣ½ -560,illegal a.ߴҺ -561,illness n. -562,image n.磻ɨ -563,imaginary a.вٲȵ -564,imagination n. -565,imagine vt.Ƿ˨룻Ͼ -566,immigrant n. a.ƫ -567,immune -568,impact n.䣬ã -569,impatient a.ͷģ޵ -570,implication n.壬ʾָ -571,import vt.&n. -572,importance n.ҪҪ -573,important a.ܵģϨå -574,impose vt.ѡӣ(˰) -575,impress vt. -576,impression n.ӡ̾ӡ -577,impressive a.ӡ©̵ -578,include vt. -579,income n.룻ֲ -580,increase vt.&vi.&n. -581,increasingly ad.⣬ԽԽ -582,independence n. -583,independent a.ģߵ -584,indicate vt.Ȫʾ -585,indication n.ָʾʾ -586,indifferent a.䶽ģ -587,indignant a.õģ -588,indispensable a.سյٵģ̶ -589,individual a.߱ģط -590,industrial a.ģҵ -591,industrialize vt.ʹҵ -592,industry n.˫ҵҵ -593,infant n.Ӥ a. -594,infect vt.д -595,inferior a.ȵģȵ -596,infinite a.޵ģ͸ -597,influence n.Ӱã vt. -598,influential a.е캢ȨҤ -599,inform vt.֪ͨ򡭹 -600,information n.ϢϢ֪ -601,inhabit vt.סţϢ -602,inhabitant n.ţ -603,inherit vt.̳(ͳ) -604,initial a.ģ -605,inner a.ģĵ -606,insist vi.֪Ҫ -607,inspect vt.飬ݣ -608,inspection n.飬ŷ -609,inspire vt.裻ˡ -610,instance n.壬 -611,instinct n.ܣֱ -612,insurance n.շ -613,insure vt.Ӥ -614,intellectual n.ʶ a. -615,intelligence n.Цı -616,intelligent a.ϳģǵ -617,intend vt.¶㣻ָ -618,intense a.ǿУߵ -619,intensity n.ݣңǿ -620,intensive a.Ƿǿͣ͹ϸ -621,intention n.ι -622,intentional a.ʸʵģбʶ -623,interaction n.໥ףȸ -624,interfere vi.棬Ԥ -625,interference n.ȳɽ -626,interior a.죻ɵضn.ڲ -627,intermediate a.мݣм -628,internal a.ڵģڵ -629,international a.翮Ե -630,interpret vt.ͣӽ -631,interpretation n.ͣѰ -632,interpreter n.Աײ -633,interrupt vt.ùֹ -634,interruption n.ж.˦ϰ -635,interval n.˼ó -636,interview n.᫣ -637,invest vt.ͶУͶ -638,investigate vt.&vi. -639,investigation n.ɣ -640,investment n...ͶʶͶ -641,invisible a.ܣ -642,invitation n.ϳд -643,involve vt.ۣǣ -644,isolate vt.Ը룬ʹҶ -645,jam n.ν -646,jam vt.ʹ϶ -647,jealous a.ʼɵģ -648,justice n.壬棻˾ -649,justify vt.֤ -650,keen a.ƻģҵ -651,keeper n.ɼ¥Ա -652,label n.ǩʼǣ -653,laboratory n.ʵңо -654,labour n. -655,lack vi.&vi.&n.ȱ -656,landlady n.ŮŮŴ -657,landlord n.磬 -658,lately ad.޾ǰ -659,lawsuit -660,lead vt.Ϊ· -661,leader n.ף쵼飻 -662,leadership n. -663,leading a.ָģ -664,learned a.úģѧ -665,least a.ɪ ad. -666,legal a.еģϷ -667,leisure n.䣻 -668,length n.æȣһ -669,lessen vt.ꣻ -670,liar n.ƿѵ -671,liberal a.ǭң꿮 -672,liberate vt.ţͷ -673,liberation n. -674,liberty n.³ͷţ -675,librarian n.ݹ -676,lighten vt.ȡ -677,linger -678,limb n.Ÿ֦ͣ -679,log n.ľҾ -680,logic n.߼ǣ߼ -681,logical a.ߵѵģ߼ -682,loom -683,luxury n.ݳޣŮسƷ -684,machine n.е -685,maintain vt.֣ά -686,maintenance n.֣֣ -687,major a.ϰ n.ҵ -688,majority n. -689,mark -690,marked -691,male a.еģ n. -692,manage vt.跨뷺 -693,management n.𣻾Ӫ -694,manager n.¯ -695,manual a. n.ܲ -696,manufacture vt.n.죻 -697,manufacturer n.Ƽɣ쳧 -698,margin n.ҳֽ -699,marriage n.飬䣻 -700,Marxisim n.ȿ˼ -701,Marxist a.˼ -702,master n.ˣ֣˶ -703,masterpiece n. -704,merchant n.ˣ -705,merit n.մŵ㣻 -706,microphone n.Ĵ꣬˷ -707,microscope n.± -708,milestone -709,mineral n. a. -710,minor a.ģҪ -711,minority n.Ͱ -712,miserable a.ʹĮȫ -713,mislead vt.ʹ; -714,mistake n. vi.⣬Ū -715,misunderstand vt..߳. -716,mobile a.ģ« -717,mode n.ʽʽ -718,model n.ذ룻ģģ -719,moderate a.º͵ģнթˣ -720,modern a.ָģ -721,modest a.нھ -722,motion n.ܶƣ -723,motivate vt.ߣ -724,motive n.Σõ -725,mount vt.ϣ n. -726,movement n.죬ƶ -727,multiple a.֣ -728,multiply vt.ӣ̴ -729,museum -730,musical a.ĸԣг -731,musician n.ֵڣʻ -732,noble a.եõģ鴺 -733,nonsense n.˵ѻ -734,noticeable a.׵ǵģҪ -735,nuisance n.Ķ -736,numerous a.ڶϣ״ -737,object n.ϣĿ -738,object vi.ԣ -739,objection n.ׯ飻ϲ -740,objective a.θ۵ģƫŵ -741,obtain vt.ĵãõ -742,obvious a.ﱣ׼ -743,odd a.ģֻ -744,opponent n.֣ۣԻ -745,opportunity n.λᣬԻ -746,oppose vt.ԣµ -747,opposite a.ʪ n. -748,oppress vt.ȣƣ -749,order n.֣׮ vt. -750,organ n.٣ܸ -751,organic a.ģٵ -752,organism n.壻л -753,organization n.壻壬ο -754,organize vt.˽֯ -755,oriental a.ģҵ -756,orientation -757,origin n.Դ -758,original a.ѩӱ -759,outcome n.ѡɹ -760,outlet n.ףDz -761,outline n.Ʒãͼ -762,outlook n.۲ӷ -763,output n. -764,outset n.ʼ -765,outskirt n.ߣ -766,outstanding a.ͻģܳ -767,overcoat n.£ -768,overcome vt.˷ -769,overhead a.ģҡ -770,overlook vt.磻 -771,overnight ad.ҹͻȻ -772,overtake vt.׷ϣѹ -773,ownership n.ι(Ȩ) -774,partial a.ֵģƽ -775,partially ad. -776,participate vi.룬μӣ -777,passport n. -778,patience n.㣬̣ -779,patient a. n. -780,payment n.ְ֧ĵ -781,peak n.ɽ a.ߵ -782,peep vi.(ӷ϶)͵ -783,percentage n.ȣֿ֮ -784,permanent a.õģ־õ -785,permanently ad.õأ־õ -786,permission n.ɣͬ -787,permit vt.׮ n.äʭ -788,persist vi.ӵִ -789,personal a.˵ģ -790,personnel n.ȫܣȫְԱ -791,perspective n.У辰۵ -792,persuade vt.ì vi.˵ -793,pessimistic a.ѵģ -794,pest -795,petrol n.(Ӣ) -796,petroleum n.ʯ -797,phenomenon n. -798,physical a. -799,physician n.ҽڿҽ -800,physicist n.ü -801,physics n.ѧ -802,pipeline n. -803,polite a.òģн -804,political a.Ƣģ -805,politician n.߾ -806,port n.α -807,poise -808,pour -809,positive a.ȷģڻ -810,postpone vt.ӰƳ٣̱ -811,practical a.䣻ú -812,precaution n.Ԥ -813,precious a.б -814,predict v.ԤԣԤ -815,preface n.ԣԣŵ -816,preferable a.ȡ飬 -817,preference n.룻ȳ -818,prejudice n.ƫɼ -819,prescribe vt.() -820,preserve vt.ף״棻翿 -821,prevent vt.Ԥֹֹ -822,previous a.ģǰ ad. -823,previously ad.ǰ -824,primarily ad.ȣܾٵ -825,primary a.صģƶ -826,prime a.Ҫ n. -827,primitive a.ԭʼģֻ -828,profession n.ְҵ -829,professional a.ְҵn.רҵԱ -830,professor n. -831,progress n.ſź -832,progressive a.ǣǰʼ -833,prominent a.ģͻ -834,promise n.ԣָ vt.޴ -835,promising a.ģ; -836,promote vt. -837,prompt a. vt.ش -838,proposal n.񣬽飻¸ -839,propose vt. vi. -840,prospect n.չǰճ -841,prosperity n.ڣʢ -842,prosperous a.ٵ磬ʢ -843,protest vt.&vi.&n. -844,psychological a.ֺۣ -845,publication n.䲼棻ư -846,publish vt. -847,puppet n.ͷżż -848,purpose n.ĿģͼЧ -849,radar n.̴ߵڲ -850,radiate vi.أ -851,radiation n.䣬 -852,radioactive a.ŵԳ -853,radioactivity n.ԣ() -854,random -855,rat n. -856,rational a.ࣻ -857,ray n.ߣѮ -858,react vi.ӦӰ -859,reaction n.£ -860,reality n.ʵͥʵ -861,reasonable a. -862,rebel vi.췴 n.췴 -863,rebellion n.컹ˣվ -864,recall vt.ޣŻأ̨ -865,reception a.дſ -866,recognition n.ϣ -867,recognize vt.ʶϳ -868,recollect vt.ؽ䣬 -869,recover vt. -870,recovery n.ػְ -871,refine vt.&vi.ᴿ -872,reform vt.&n.ĸ -873,refresh -874,refreshment n.㣬Ƭ -875,refusal n. -876,refute vt.̳⣬ţԵ -877,regard vt.ѡ԰ -878,regarding prep. -879,regardless ad.һе -880,region n.ܣǣ -881,regulate vt.ƣ -882,regulation n.򣬹м -883,reign n.ͳ֧ -884,rein n. vi.Ԧӻ -885,reinforce vt.Ԯ֧Ԯǿ -886,reject vt.зʱ -887,rejoice vi.ϲ -888,relate vt.ձϵ -889,relation n.ϵͱի -890,relationship n.ز -891,relative a.йϵģԵ -892,relatively ad.Э飬Ƚϵ -893,relativity n.ӹԣ -894,relevant a.ոк -895,reliability n. -896,reliable a.ɿ϶˵ -897,reliance n.ΣͶ -898,religion n.Ḳ̌Ħ -899,religious a.ڱ -900,reluctant a.Ըģǿ -901,rely vi. -902,remain vi.ʣ£ -903,remains n.󦣬𣻷κ -904,remark vt.&vi.&n.ų̸֫ -905,remarkable a.쳣ģȺ -906,remind vt.ѣ -907,remote a.Զ۶ -908,removal n.ƶƣ -909,remove vt.ƶѵ -910,replace vt.ԺŶ˪ -911,represent vt.ߣűϬ -912,representative a. n. -913,reproduce vt.&vi.ᣬ -914,reserve vt. -915,resign vt. vi.ְ -916,resignation n.Թɣտ -917,resist vt.&vi.ֿ -918,resistance n.̿ԡ -919,resistant a.ɵģХ -920,resolution n.ߣ -921,resolve vt.Ӿ n. -922,resolution -923,resource n.Դ޻ -924,respect n.&vt.ϱ -925,respectful a.ˢ -926,respective ȵģ -927,respectively ad.ͣ -928,respond vi.â -929,response n.𣬻شӭӦ -930,responsibility n.Σְ -931,responsible a.պβ -932,restaurant n.ݣ꣬ -933,restless a.аϣ -934,restore vt.ָţIJ -935,restrain vt.ƣ -936,restraint n.ᾩƣ˩ -937,restrict vtƣ޶̧ -938,restriction n.Լ -939,resume vt.ָػձ -940,retain vt.֣ -941,retell vt.ٽα -942,retire vi.Ҽҩ -943,reverse vt.ܣת n.ȱ -944,review vt. n.ϰ -945,revise vt.ٶ׶ -946,rival n. a.ȼ -947,roar vi.У n. -948,rocket n.צ -949,roll vi.&vt.̻ת -950,romantic a.ģη澨 -951,route n.ͣߣ۳ -952,routine n.й a. -953,ruler n.ߣߣֱ -954,rumour n.ԣҥ -955,saint n.ʥͽٽͽ -956,salad n.ɫΣݫģ -957,sample n.Ʒʵ걾 -958,saving n.ۣԼ -959,scan vt.̵ŧ -960,scarcely ad. -961,schedule n.ʱ -962,scheme n.ƺ滮 -963,scholar n.(ѧ) -964,scholarship n.ѧҵѧ -965,scientific a.ѧ() -966,scientist n.()ѧ -967,scope n.ɥ౾ -968,scorn n. vt.ȿ -969,seaport n.ͣ -970,secondary a.յҪ -971,secondly ad.ڶ()Ҥ -972,secure a.ɰ -973,security n.ߣȫ -974,seek vt.ң̽ԯƵ -975,selection n.ѡ⣬ѡѡͨ -976,selfish a.˽ģ˽ -977,senior a.Ȱٵģز -978,sense n.й٣оʶ -979,sensible a.̻浽棻Ǻ -980,sensitive a.ǣ -981,shampoo vt.ũ n. -982,shift vt.̻ n. -983,shilling n.ȴ -984,shortage n.룬ȱ٣վ -985,shortcoming n.Ǹ -986,shriek vi.ߺ n.Ѻ -987,significance n.壬ζҪ -988,significant n.ֵģҪ -989,single a.һģ -990,singular a.һ£Ƿ -991,slave n.ūȼ -992,slavery n.ūȣ -993,slight a.dzŷ΢ -994,slightly ad.΢ -995,sly a.⻫ģդ -996,smooth a.ƽƽ -997,smoothly ad.ͻأƽȵ -998,socialism n. -999,socialist a. -1000,society n.᣻ǣǦ -1001,solely ad.أһ -1002,solemn a.ׯϵģص -1003,sore -1004,sour -1005,sorrow -1006,soluble a.ܵģպ -1007,solution n.ĭ -1008,solve vt.𣬽ã -1009,sophisticated a.ʵģ -1010,sophomore -1011,special a.ģ -1012,specialist n. -1013,speciality n.ְ -1014,specialize vi.ΪרͰ -1015,specially ad.רŵأر -1016,specific a.ѣ -1017,specify vi.ָ˲ϸ˵ -1018,sew -1019,sow -1020,spur n.پ෯ vt.˼ -1021,square n.ԸΣ㳡 -1022,stare -1023,stability n.ȶȶԣ -1024,stable a.ȶģҲ -1025,stain vt.ȴ -1026,standpoint n.䣬 -1027,startle vt.Ѵͽ n.Ҵ -1028,starve vi. vt.ʹ -1029,state vt.ʮ -1030,statement n. -1031,statesman n.μң -1032,stimulate vt.̼¦޵ -1033,sting vt.̣ vi.&n.Ĺ -1034,strain vt. vi. -1035,stranger n.İ죻¹ -1036,strength n.ģ̿ -1037,strengthen vt.ӽ -1038,submarine a.ֳ n.DZȷ -1039,submerge vt. vi.ˮ -1040,sue -1041,suit -1042,substance n.ʣҶּ -1043,substantial a.䣻 -1044,substitute n.ӯ vt.á -1045,subtract vt.ȥ -1046,suburb n.⣬ -1047,subway n.ؿ飻· -1048,superficial a.ģ콲 -1049,superior a.ϴģԽ -1050,supreme a.ߵģ -1051,suspect vt. vi. -1052,suspicion n.ɣ㲲ܣ -1053,sustain vt.ţ̳ -1054,sympathetic a.æĵ֣гī -1055,sympathize vi.ͬ飻ͬէ -1056,sympathy n.Ʒһ£ͬ -1057,system n.ϵͳͼ -1058,systematic(al) a.ͳģмŻ -1059,talent n.ˤ -1060,tank n.Ͼˣ -1061,teenager n. -1062,temple n.ʥã֨ -1063,temporary a.ʱģҩʱ -1064,tempt vt.ìЦΥ -1065,temptation n. -1066,thorough a.ҵǽɲ -1067,thoughtful a.˼ģ -1068,thrive vi.٣ -1069,tolerance n.̣ -1070,tolerate vt.Һˡ -1071,transfer vt.ƣvi.תͣ -1072,transform vt.Ʊ䣻ä죻任 -1073,transformation n.仯죻 -1074,transformer n.ײ -1075,transistor n.ô -1076,translate vt.룬 vt. -1077,translation n.ģ뱾 -1078,transmission n.ν -1079,transmit vt.ʣ -1080,transparent a.õģʶƵ -1081,transport vt. n. -1082,transportation n.䣬. -1083,treasure n.߸ vt.䶭 -1084,triangle n.() -1085,tribe n.ӿ䣬 -1086,troublesome a.ģݷ -1087,turning n.תߣתҴ -1088,twinkle vi.˸ҫ -1089,typical a.㣬Ե -1090,unbearable a.ѿģǴ -1091,uncertain a.޹٣ -1092,uncomfortable a.ģ -1093,unconscious a.ʡµ -1094,uncover vt.衭ĸdz -1095,undergo vt.ܣ -1096,undergraduate n.Ҷѧ -1097,underground a.µģƴµ -1098,underline vt.ƣδ -1099,undertake vt.ӴԲ䣻֤ -1100,undertaking n.񣬴ҵ -1101,undoubtedly ad.öڶ -1102,uneasy a.ܲģǵ -1103,unexpected a.벻͵ģ -1104,unfair a.ƽذ -1105,uniform a.һ n.Ȭ -1106,union n.ϣŽ᣻Э -1107,unique a.Ψģһ޼ -1108,unit n.λԪü -1109,unite vi.ĺ vt.ʹ -1110,unity n.һͳһŽ -1111,universal a.ģ -1112,universe n.٣ -1113,university n.ѧ -1114,unjust a.ʰШ乫õ -1115,unload vt.ж() vi.ж -1116,unpleasant a.˫ã -1117,unstable a.ȹ̵ģı -1118,unusual a.ƽ -1119,unusually a.ƽߣ -1120,unwilling a. -1121,upright a.ֱģֱ -1122,upset vt.Ū򷭣Ҹ -1123,upside-down a.ߵģ̾ե -1124,upstairs ad. a. -1125,up-to-date a.ֱУ -1126,urge vt.߶ n. -1127,urgent a.뼱裻ǿ -1128,usage n.ʹЩٴ֫귨 -1129,usual a.ͨ -1130,utility n.ããʵ -1131,utilize vt. -1132,utmost a.ԶƧ n. -1133,valid a.ä£Ӿ -1134,valley n.()Ϫȣ -1135,valuable a.ֵֵ -1136,value n.۸ vt. -1137,variable a.۵ n.̵ -1138,variation n.֮ף䶯 -1139,variety n.ҹ߻ -1140,various a.ģ޵ -1141,vary vt.䣻 -1142,vast a.ģƸ -1143,vegetable n.ֲ߲ -1144,vehicle n.Խ -1145,velocity n.ٰ -1146,venture n.&vi. vt.ױ -1147,vice n.񣻻ӣȱ -1148,victim n.ߣ -1149,victorious a.ʤģ -1150,victory n.ʤʤ -1151,viewpoint n.أ -1152,vigorous a. -1153,visible a.ģҼ -1154,vision n.֣λ -1155,visitor n.ߣμ -1156,visual a.ģ -1157,vital a.ޱ£н -1158,vitamin n.άޣά -1159,vivid a.ʶѣ˱ -1160,vocabulary n.ʻ裻ѭٻ -1161,voice n.̬ -1162,volcano n.ɽ -1163,volleyball n.춯 -1164,volt n.¿أ -1165,volume n.ꣻ㲻 -1166,voluntary a.Ը˳־Ӳ -1167,warn vt. vi.澯 -1168,waterfall n.ٲ -1169,weaken vt.ʽ vi. -1170,weakness n. -1171,wealth n.ѿ㣬ƹ㣻 -1172,wealthy a.ģԣ -1173,weapon n.Ш -1174,weary a.ƣ vt.ʹƣ -1175,welfare n. -1176,whistle n.˼ vi. -1177,widen vt.ӿ vi. -1178,widespread a.ģ߶ -1179,withstand vt.Ů -1180,witness n.ݣ֤ vt. -1181,workshop n.հ䣬 -1182,world-wide a.ȫ -1183,worse a. ad. -1184,worship n.񻧣 vt.հ -1185,worthless a.޼׶ģõ -1186,worthwhile a.Ӭ -1187,worthy a.кֵģֵõ -1188,wound n. vt.ʹ -1189,writing n.дд -1190,wrong a. ad.¡ֿ -1191,X-ray n.XϺȣX -1192,yawn vi.Dz n.Ƿ -1193,yearly a.ÿ ad.һ -1194,youth n.ǣ -1195,youthful a.ģ -1196,youngster -1197,zeal n.ģ飬ȳ -1198,zealous a.լĵģ -1199,zebra n. -1200,zone n.򣬷Χ diff --git a/pythonProject/mysqlconnect.py b/pythonProject/mysqlconnect.py index 49cac61..99e2509 100644 --- a/pythonProject/mysqlconnect.py +++ b/pythonProject/mysqlconnect.py @@ -1,36 +1,32 @@ -import pymysql -#import cryptography -# 数据库连接配置 -db_config = { - 'host': 'localhost', # 数据库地址 - 'user': 'Mysql', # 数据库用户名 - 'password': '2141203017', # 数据库密码 - 'database': 'word', # 数据库名 - 'charset': 'utf8mb4', # 字符编码 -} +import tkinter as tk +from tkinter import messagebox -# 待插入的数据 -data_to_insert = [ - ('1', 'abandon vt.旬弃;形弃,萨瑟'), - ('2', 'ability n.能力;能耐,乃炸'), - # ... 其他数据 ... - # 注意:这里的每一项都是一个元组,格式为(序号, 内容) -] +# 单词列表 +words = ["apple", "banana", "cherry", "date", "elderberry"] -# 连接数据库并尝试插入数据 -try: - connection = pymysql.connect(**db_config) - cursor = connection.cursor() +class WordApp(tk.Tk): + def __init__(self): + super().__init__() + self.title("单词学习") + self.current_word_index = 0 + self.word_label = tk.Label(self, text="", font=("Helvetica", 20)) + self.word_label.pack(pady=20) + self.create_buttons() - # 执行批量插入 - for item in data_to_insert: - xuhao, neirong = item - insert_sql = "INSERT INTO word (xuhao, neirong) VALUES (%s, %s)" - cursor.execute(insert_sql, (xuhao, neirong)) + def create_buttons(self): + self.know_button = tk.Button(self, text="认识", command=self.show_next_word, width=10) + self.not_know_button = tk.Button(self, text="不认识", command=self.show_next_word, width=10) + self.know_button.pack(side=tk.LEFT, padx=10, pady=10) + self.not_know_button.pack(side=tk.RIGHT, padx=10, pady=10) - # 提交事务 - connection.commit() - print("数据插入成功!") -except Exception as e: - print(f"数据插入失败,错误信息:{e}") + def show_next_word(self): + if self.current_word_index < len(words): + self.word_label.config(text=words[self.current_word_index]) + self.current_word_index += 1 + else: + messagebox.showinfo("结束", "所有单词已学习完毕!") + self.destroy() +if __name__ == "__main__": + app = WordApp() + app.mainloop() \ No newline at end of file diff --git a/pythonProject/test.py b/pythonProject/test.py index 7285181..681874e 100644 --- a/pythonProject/test.py +++ b/pythonProject/test.py @@ -27,7 +27,7 @@ filename = 'extracted_data.csv' with open(filename, 'w', newline='', encoding='utf-8') as csvfile: csvwriter = csv.writer(csvfile) # 写入表头 - csvwriter.writerow(['序号', '内容']) + csvwriter.writerow(['序号', '内容','']) # 写入数据 for row in data: # 注意,原问题没有明确"单词"来源,这里假设每条数据只有序号和内容两列 diff --git a/pythonProject/test1.py b/pythonProject/test1.py index 4f4571e..4c5eb7e 100644 --- a/pythonProject/test1.py +++ b/pythonProject/test1.py @@ -1,141 +1,8 @@ -import sqlite3 -import random -import tkinter as tk -from tkinter import Toplevel - -# 数据库连接与初始化 -def init_db_connection(): - conn = sqlite3.connect('word_database.db') - cursor = conn.cursor() - cursor.execute('CREATE TABLE IF NOT EXISTS Words (word TEXT, meaning TEXT, learned INTEGER)') - conn.commit() - return conn - -# 获取未学习的单词 -def get_unlearned_word(conn): - cursor = conn.cursor() - cursor.execute('SELECT word, meaning FROM Words WHERE learned = 0 ORDER BY RANDOM() LIMIT 1') - result = cursor.fetchone() - if result: - return {'word': result[0], 'meaning': result[1]} - return None - -# 标记单词为已学习 -def mark_learned(word, conn): - cursor = conn.cursor() - cursor.execute('UPDATE Words SET learned = 1 WHERE word = ?', (word,)) - conn.commit() - -# 初始化主窗口 -root = tk.Tk() -root.title("单词学习系统") - - -def open_new_window1(conn): - new_window = Toplevel(root) - new_window.title("新单词") - - def learn_next_word(): - word = get_unlearned_word(conn) - if word: - label_word.config(text=word['word']) - label_meaning.config(text=word['meaning']) - current_word = word['word'] - else: - tk.messagebox.showinfo("提示", "没有更多新单词了!") - - def review_previous(): - # 实现回顾逻辑(这里简化处理,实际可能需要维护一个历史单词队列) - pass - - current_word = get_unlearned_word(conn) - if current_word: - label_word = tk.Label(new_window, text=current_word['word']) - label_word.pack() - - label_meaning = tk.Label(new_window, text=current_word['meaning']) - label_meaning.pack() - - button_next = tk.Button(new_window, text="下一个单词", command=learn_next_word) - button_next.pack() - - button_review = tk.Button(new_window, text="回顾", command=review_previous) - button_review.pack() - else: - tk.messagebox.showinfo("提示", "没有新单词!") - -def open_new_window2(conn): - def check_spelling(): - user_input = entry_spelling.get().strip() - if user_input.lower() == current_review_word['word']: - label_spelling.config(bg='green') # 标记为绿色表示正确 - mark_next_review(conn) # 正确后标记下一个复习 - else: - label_spelling.config(bg='red') # 错误则标记为红色 - messagebox.showerror("错误", "拼写错误,请重试。") - - def review_previous_word(): - global current_review_word - # 实现回顾前一个单词的逻辑,这里简化处理,假设我们有一个全局变量或列表来追踪复习单词 - # 实际应用中,可能需要维护复习单词的历史栈 - pass - - def mark_next_review(conn): - # 假设复习完当前单词后自动标记下一个为复习状态,实际逻辑可能更复杂 - global current_review_word - next_word = get_learned_word(conn) - if next_word: - current_review_word = next_word - label_meaning.config(text=next_word['meaning']) - entry_spelling.delete(0, tk.END) # 清空输入框 - label_spelling.config(text="", bg='white') # 重置标签颜色和内容 - else: - messagebox.showinfo("提示", "没有更多复习单词了!") - - new_window = Toplevel(root) - new_window.title("复习单词") - - current_review_word = get_learned_word(conn) - if current_review_word: - label_meaning = tk.Label(new_window, text=current_review_word['meaning'], wraplength=200) - label_meaning.pack(pady=10) - - label_spelling = tk.Label(new_window, text="", width=20, bg='white') - label_spelling.pack(pady=5) - - entry_spelling = Entry(new_window) - entry_spelling.pack(pady=5) - - button_check = tk.Button(new_window, text="检查拼写", command=check_spelling) - button_check.pack(side=tk.LEFT, padx=5) - - button_prev = tk.Button(new_window, text="回顾前一个", command=review_previous_word) - button_prev.pack(side=tk.LEFT, padx=5) - - else: - messagebox.showinfo("提示", "没有复习单词!") - new_window = Toplevel(root) - new_window.title("复习单词") - - - - - -def open_new_window3(conn): - new_window = Toplevel(root) - new_window.title("易错单词") - - # 同样,易错单词窗口逻辑需根据错误记录定制,这里简化处理 - pass - - -button1 = tk.Button(root, text="学习新单词", command=lambda: open_new_window1(init_db_connection())) -button1.pack(pady=10) - -button2 = tk.Button(root, text="复习单词", command=lambda: open_new_window2(init_db_connection())) -button2.pack(pady=10) - -button3 = tk.Button(root, text="易错单词", command=lambda: open_new_window3(init_db_connection())) -button3.pack(pady=10) - -root.mainloop() \ No newline at end of file +序号,内容 +1,abandon vt.丢弃;放弃,抛弃 +2,ability n.能力;能耐,本领 +3,abnormal a.不正常的;变态的 +4,aboard ad.在船(车)上;上船 +5,abroad ad.(在)国外;到处 +以上的csv文件,创建一个窗口,并设置一个按钮实现记单词的功能,随机依次弹出固定数量的单词,比如一次性弹出五个单词, +将五个单词依次弹出,并在单词下面创建两个按钮,认识和不认识,当点击按钮后显示下一个单词,直到五个单词显示完 \ No newline at end of file diff --git a/pythonProject/test2.py b/pythonProject/test2.py new file mode 100644 index 0000000..82e3858 --- /dev/null +++ b/pythonProject/test2.py @@ -0,0 +1,47 @@ +import tkinter as tk +import csv +import random +from struct import pack + + +# 从CSV读取数据 +def read_words_from_csv(file_path): + with open(file_path, 'r', encoding='utf-8') as csvfile: + reader = csv.reader(csvfile) + next(reader) # 过表头 + return list(reader) + +# 随机选取固定数量的单词 +def select_random_words(words, count=5): + return random.sample(words, count) + +# 创建并显示单词及按钮 +def display_words(window, words, word_index, total_words): + if word_index < total_words: + number, word = word_index + 1, words[word_index][1] + tk.Label(window, text=f"{number}: {word}", font=("Arial", 12)).pack(pady=5) + tk.Button(window, text="认识", command=lambda: next_word(window, word_index +1)).pack(side=tk.LEFT, padx=10, pady=5) + tk.Button(window, text="不认识", command=lambda: next_word(window, word_index)).pack(side=tk.RIGHT, padx=1, pady=5) + else: + tk.Label(window, text="所有单词已显示完毕", font=("Arial", 14, 'bold')).pack() + +def next_word(window, word_index, total_words): + window.destroy() + new_window = tk.Toplevel() + new_window.title("单词学习") + display_words(new_window, word_index, total_words) + +# 主程序 +def main(): + # 读取单词 + words = read_words_from_csv('words.csv') + window = tk.Tk() + window.title("单词学习器") + tk.Button(window, text="开始背单词", + command=lambda: display_words(tk.Toplevel(), 0, len(words))), + pack(pady=10) + window.mainloop() + + +if __name__=='__main__': + main() \ No newline at end of file diff --git a/pythonProject/words.csv b/pythonProject/words.csv new file mode 100644 index 0000000..ef9aec4 --- /dev/null +++ b/pythonProject/words.csv @@ -0,0 +1,71 @@ +序号,内容 +1,abandon vt.丢弃;放弃,抛弃 +2,ability n.能力;能耐,本领 +3,abnormal a.不正常的;变态的 +4,aboard ad.在船(车)上;上船 +5,abroad ad.(在)国外;到处 +6,absence n.缺席,不在场;缺乏 +7,absent a.不在场的;缺乏的 +8,abstract a.抽象的 n.摘要 +9,abundant a.丰富的;大量的 +10,abuse vt.滥用;虐待 n.滥用 +11,access n.接近;通道,入口 +12,accompany vt.陪伴,陪同;伴随 +13,accomplish vt.达到(目的);完成 +14,account n.记述;解释;帐目 +15,accuse vt.指责;归咎于 +16,accustom vt.使习惯 +17,accustomed a.惯常的;习惯的 +18,achieve vt.完成,实现;达到 +19,achievement n.完成;成就,成绩 +20,acquaintance n.认识;了解;熟人 +21,act vi.行动;见效 n.行为 +22,action n.行动;作用;功能 +23,active a.活跃的;积极的 +24,activity n.活动;活力;行动 +25,actress n.女演员 +26,actually ad.实际上;竟然 +27,acute a.尖的,锐的;敏锐的 +28,add vt.添加,附加,掺加 +29,addition n.加,加法;附加物 +30,additional a.附加的,追加的 +31,address n.地址;演说;谈吐 +32,adjust vt.调整,调节;校正 +33,administration n.管理;管理部门 +34,admire vt.钦佩,羡慕,赞赏 +35,admission n.允许进入;承认 +36,admit vt.承认;准许…进入 +37,advance vi.前进;提高 n.进展 +38,advanced a.先进的;高级的 +39,advantage n.优点,优势;好处 +40,adventure n.冒险;惊险活动 +41,adult +42,advertisement n.广告;登广告 +43,advisable n.明智的;可取的 +44,advise vt.劝告;建议;通知 +45,affect vt.影响;感动 +46,affection n.慈爱,爱;爱慕 +47,afford vt.担负得起…;提供 +48,aggressive a.侵略的;好斗的 +49,agony n.极度痛苦 +50,agreement n.协定,协议;同意 +51,agriculture n.农业,农艺;农学 +52,aid n.帮助,救护;助手 +53,airline +54,alphabet n.字母表,字母系统 +55,alter vt.改变,变更;改做 +56,alternative n.替换物;取舍,抉择 +57,although conj.尽管,虽然 +58,altitude n.高,高度;高处 +59,altogether ad.完全;总而言之 +60,amaze vt.使惊奇,使惊愕 +61,ambition n.雄心,抱负,野心 +62,ambitious +63,ambulance n.救护车;野战医院 +64,amplify vt.放大,增强;扩大 +65,amuse vt.逗…乐;给…娱乐 +66,angel n.天使,神差,安琪儿 +67,anger n.怒,愤怒 vt.使发怒 +68,angle n.角,角度 +69,ankle n.踝,踝节部 +70,a