陳以鈞python集合set字典dict統計字元數目37,241不同字元數1,251

STYLE='BORED: 9PX RED DASHED'>
file = open('金融常識.txt','r',encoding='utf-8')
reading = file.read()
file.close()
print('檔案字元characters數:', len(reading))
mySet = set(reading)
myDict = dict()
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. 1030.商業軟體。https://tyuiop715547.blogspot.com/2026/10/excelandorcountcountifindirect.html
    1016.商業軟體。https://tyuiop715547.blogspot.com/2026/10/excelmatchindexisnumber.html
    1019.input.https://tyuiop715547.blogspot.com/2026/10/pythoninputfind-1.html
    1012.字典.https://tyuiop715547.blogspot.com/2026/10/pythonsetdict372411251.html

    回覆刪除

張貼留言

這個網誌中的熱門文章

陳以鈞EXCEL的函數FIND,LEN,LEFT,MID,RIGHT,POWER,UNICHAR,UNICODE

陳以鈞excel字串處理產生金融市場常識

陳以鈞excel名稱方塊AND,OR,COUNT,COUNTIF,INDIRECT間接定向