林岑庭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:,}')
1030.軟體應用。看不到你有使用名稱方塊的定義名稱。https://lin-cen-ting.blogspot.com/2026/10/excelandorcountcountifindirect.html
回覆刪除1016.商業軟體。https://lin-cen-ting.blogspot.com/2026/10/excelmatchindexisnumber.html
1019.input沒有完整呈現。https://lin-cen-ting.blogspot.com/2026/10/pythoninputfind-1.html
input要使用pre才能清楚呈現。https://lin-cen-ting.blogspot.com/2026/10/pythonsetdict37241.html