劉任昌python集合set字典dict統計字元數目37,241不同字元數1,251

file = open('金融常識.txt','r',encoding='utf-8')
reading = file.read()
file.close()
print('檔案字元characters數:', len(reading))
mySet = set(reading)#將串列轉成集合,稱她 mySet得到1251
myDict = dict()     #定義字典dict稱他為 myDict例如改成DoraSet
for j in mySet:
    myDict[j] = 0
for i in reading:
    myDict[i] += 1
for j in mySet:
    print(f"字元「{j}」出現{myDict[j]:,}次數")
print(f'字元數目{len(reading):,},不同字元數{len(mySet):,}')
#python和其他所有語言不同的特徵 f string格式化字串文字
print(f"劉任昌統計左引號(出現次數{myDict['(']:,}")
print(f'劉任昌統計右引號)出現次數{myDict[")"]:,}')
print(f'劉任昌統計504每題四個選項至少有{504*4:,}')

留言

  1. https://alston123773.blogspot.com/2026/10/pythonsetdict372411251.html

    回覆刪除
  2. https://glacier0831.blogspot.com/2026/10/pythonsetdict372411251.html

    回覆刪除
  3. https://hannie0-hannie.blogspot.com/2026/10/pythonsetdict372411251.html

    回覆刪除
  4. https://julian696969.blogspot.com/2026/10/pythonsetdict372411251.html

    回覆刪除
  5. https://guojhenglong.blogspot.com/2026/10/pythonsetdict372411251.html

    回覆刪除
  6. https://mina-zi.blogspot.com/2026/10/pythonsetdict372411251.html

    回覆刪除
  7. https://ding-zi-qin.blogspot.com/2026/10/pythonsetdict372411251.html

    回覆刪除
  8. https://chang-wen-yuan.blogspot.com/2026/10/pythonsetdict372411251.html

    回覆刪除
  9. https://cenruri.blogspot.com/2026/10/pythonstedict372411251.html

    回覆刪除
  10. https://cherylevangeline.blogspot.com/2026/10/pythonsetdict372411251.html

    回覆刪除
  11. https://123wqeasd.blogspot.com/2026/10/pythonsetdict372411251.html

    回覆刪除
  12. https://ruoyiiiiii.blogspot.com/2026/10/pythonsetdict372411251.html

    回覆刪除
  13. https://liuyidi.blogspot.com/2026/10/pythonsetdict372411251.html

    回覆刪除
  14. https://lutingjuan.blogspot.com/2026/10/pythonsetdict372411251.html

    回覆刪除
  15. https://sihyin0526.blogspot.com/2026/10/pythonsetdict372411251.html

    回覆刪除
  16. https://chialing112233.blogspot.com/2026/10/pythonsetdict372411251.html

    回覆刪除
  17. https://zzy317.blogspot.com/2026/10/pythonsetdict372411251.html

    回覆刪除
  18. https://serein-chen.blogspot.com/2026/10/pythonsetdict372411251.html

    回覆刪除
  19. https://lyz0216.blogspot.com/2026/10/pythonsetdict372411251.html

    回覆刪除
  20. https://1qaz1234567890.blogspot.com/2026/10/pythonsetdict372411251-10-11-2026.html

    回覆刪除
  21. https://trfbvuytrgoij.blogspot.com/2026/10/pythonsetdict372411251.html

    回覆刪除
  22. https://yeyuyu.blogspot.com/2026/10/pythonsetdict372411251.html

    回覆刪除
  23. https://pythonhtml1.blogspot.com/2026/10/pythonsetdict372411251.html

    回覆刪除
  24. https://tyuiop715547.blogspot.com/2026/10/pythonsetdict372411251.html

    回覆刪除
  25. https://yubaiyan.blogspot.com/2026/10/pythonsetdict372411251.html

    回覆刪除
  26. https://luchenning.blogspot.com/2026/10/pythonsetdict372411251.html

    回覆刪除
  27. https://www.blogger.com/blog/post/edit/7408110137795804233/4733790419532597156

    回覆刪除
  28. https://assdfwgegtehhwsjweuhnswfjikkkooojjfdr.blogspot.com/2026/10/pythonsetdict372411251_0396965530.html

    回覆刪除
  29. https://wdwddq211223d.blogspot.com/2026/10/pythonsetdict372411251.html

    回覆刪除
  30. https://www.blogger.com/blog/post/edit/preview/6969370829164329875/2681369899251757270

    回覆刪除
  31. https://www.blogger.com/blog/post/edit/preview/1070248541590854509/1831972892317880052

    回覆刪除
  32. https://kaoreki0514.blogspot.com/2026/10/pythonsetdict372411251.html

    回覆刪除
  33. https://gangyouli6.blogspot.com/2026/10/pythonsetdict372411251.html

    回覆刪除
  34. https://linhongen.blogspot.com/2026/11/pythonsetdict372411251.html

    回覆刪除

張貼留言

這個網誌中的熱門文章

劉任昌EXCEL產生網頁

劉任昌w3schools字串str串列list集合set字典dict元組tuple

內建函數print, type, ord字碼, chr字元