#Python TQC考題802 字元對應
s=input()
sum=0
for i in range(len(s)):
print(“ASCII code for ‘%s’ is %d” %(s[i],ord(s[i])))
#右邊有))) 三個,也是會錯的地方
#先寫s[i],再用ord()包覆
#chr() 則是ord()的反向,把ASCII碼轉為字母
sum += ord(s[i])
print(sum)

#再練習一次:


#多使用了list(str)的技巧
#不能用[ str ],要 list(str)
#字串才會每個字母拆開進入list中

“””
string跟list一樣,
都可以使用index定位
其實沒有非要做 =list(string)
就是list比string常用
直覺會這麼做
“””

#覺得ord( str1[i] )太長的話,可以先令他等於ord1:

# for i in str1:
#跟list的用法一樣







![Python: pandas.Series如何只保留str,去除重複值?#isinstance(x:Any, str) -> bool #.drop_duplicates() #Series.apply( function )逐元素應用function運算 #DataFrame.apply( function )逐Series應用function運算 .drop_duplicates() 跟.unique()有何差別? df.drop_duplicates() 等效於 df[~df.duplicated()] Python: pandas.Series如何只保留str,去除重複值?#isinstance(x:Any, str) -> bool #.drop_duplicates() #Series.apply( function )逐元素應用function運算 #DataFrame.apply( function )逐Series應用function運算 .drop_duplicates() 跟.unique()有何差別? df.drop_duplicates() 等效於 df[~df.duplicated()]](https://i2.wp.com/savingking.com.tw/wp-content/uploads/2024/11/20241123194900_0_5218de.png?quality=90&zoom=2&ssl=1&resize=350%2C233)




近期留言