python123 模擬試卷D綜合程式設計題

2021-09-27 01:52:22 字數 3079 閱讀 5148

import wordcloud

import jieba

from imageio import imread

defzishu

(fi1,fo1)

: ls1=

d1=for line in fi1:

for c in line:

if c!=

'\n'

: d1[c]

=d1.get(c,0)

+1ld1=

sorted

(d1.items(),\

key=

lambda x:x[1]

,reverse=

true

)#返回元組列表

("命運-網路版.txt"

,"r"

,encoding=

"utf-8"

) fi2=

open

("尋夢-網路版.txt"

,"r"

,encoding=

"utf-8"

) fo1=

open

("命運-字元統計.txt"

,"w"

,encoding=

"utf-8"

) fo2=

open

("尋夢-字元統計.txt"

,"w"

,encoding=

"utf-8"

) fp=

open

("相同字元.txt"

,"w"

,encoding=

"utf-8"

) txt1=zishu(fi1,fo1)

txt2=zishu(fi2,fo2)

samezifu(txt1,txt2,fp)

clo1(fi1,fi2,fo1,fo2,fp)

#檔案控制代碼用一次就要重新來

fi1=

open

("命運-網路版.txt"

,"r"

,encoding=

"utf-8"

) fi2=

open

("尋夢-網路版.txt"

,"r"

,encoding=

"utf-8"

) ciyun(fi1,

"命運ciyun1.bmp"

) ciyun(fi2,

"尋夢ciyun2.bmp"

) clo2(fi1,fi2)

main(

)

1.imread不再在scipy裡了

2. jieba.lcut生成的是字串列表

3. 詞云的生成用的是空格分隔的長字串

4. html5語言和markdown語言之間要加空格,比如前,html5語言行間加上br標籤

tian.jpg(mask檔案)

命運ciyun1.bmp

尋夢ciyun2.bmp

python123登入 python實現使用者登入

1.實現使用者輸入使用者名稱和密碼,當使用者名為 seven 且 密碼為 123 時,顯示登陸成功,否則登陸失敗 tag true while tag name input name passwd input password if name seven and passwd 123 print l...

計算圓周率(Python123)

根據下面的泰勒級數關係式,求圓周率的值,當最後一項的值小於給定閾值時結束。輸入在一行中給出小於1且大於0的閾值。在一行中輸出滿足閾值條件的近似圓周率,輸出到小數點後6位。k flag 1 s 0 epsilon eval input while 1 2 k 1 epsilon 當最後一項小於給定閾值...

Python123第三週下

time庫的基本介紹 time是python處理時間的標準庫 三類函式 時間獲取 time ctime gmtime 時間格式化 strftime strptime 程式計時 sleep per counter 函式的使用 時間獲取 獲取當前時間 time 獲取當前時間戳,即計算機內部時間值,浮點數...