Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

libraries - VS code [python] doesn't run properly

So i've downloaded python two weeks ago, code is working, had few problems on libraries that were interrupted due to two versions of python 3.7 & 3.9, I deleted the older one and now it CAN find the libraries but CAN'T show them..

from matplotlib.pylab import plt

abc = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',]

def countp(counter):
    count=0
    for i in counter:
        print(abc[count],"showed up ",i," times")
        count+=1

def checkfile(folder):     
    file = open(folder,"r")
    read=file
    abc = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',]
    counter = [0]*26
    #read file
    for i in file:
        # reads line
        for j in i:
            count=0
            #search one key at a time
            for k in abc:
                if (j==k.lower()):
                    #add +1 to desired letter. 
                    counter[count]+=1
                count+=1
    return counter

if __name__ == "__main__":
    folder="C:/Users/omerd/Desktop/Welp.txt"
    counter=checkfile(folder)
    countp(counter)
    x=5
    y=6
    plt.plot(x,y)
    

it does run, but it doesn't use the

    plt.plot(x,y)

line, it should open a chart, but it doesn't, not sure if newbie mistake or need to reInstall everything


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Many Documentations Don't mention this but try adding plt.show() at the after plst.plot(). plt.show() is just to open the matplotlib plot


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...