isdigit() – 判断字符串是否全是数字 [0-9]。
string1 = "12345"
string2 = "Hello123"
print(string1.isdigit()) # 输出 True,因为 string1 中全是数字
print(string2.isdigit()) # 输出 False,因为 string2 中包含字母isalpha() – 判断字符串是否全是字母 [a-zA-Z]。
string1 = "Hello"
string2 = "Hello123"
print(string1.isalpha()) # 输出 True,因为 string1 中全是字母
print(string2.isalpha()) # 输出 False,因为 string2 中包含数字isalnum() – 判断 字符串是否由字母或数字组成[a-zA-Z0-9]。
string1 = "Hello123"
string2 = "Hello, World!"
print(string1.isalnum()) # 输出 True,因为 string1 中全是字母和数字
print(string2.isalnum()) # 输出 False,因为 string2 中包含逗号和空格islower() – 判断 字符串是否全部为小写字母 [a-z]。
string1 = "hello"
string2 = "Hello"
print(string1.islower()) # 输出 True,因为 string1 中全是小写字母
print(string2.islower()) # 输出 False,因为 string2 中包含大写字母isupper() – 判断字符串是否全部为大写字母 [A-Z]。
string1 = "HELLO"
string2 = "Hello"
print(string1.isupper()) # 输出 True,因为 string1 中全是大写字母
print(string2.isupper()) # 输出 False,因为 string2 中包含小写字母
輸出結果:


推薦hahow線上學習python: https://igrape.net/30afN



![Python如何做excel的樞紐分析? groupbyObj = df.groupby([‘A’, ‘B’]) ; groupbyObj.apply() 跟 groupbyObj.agg() 差異為何? result = groupbyObj .apply( function(df) -> Series ) ; result_agg = groupbyObj .agg( [‘mean’, ‘std’] ) ; aggfunc(Series) -> float Python如何做excel的樞紐分析? groupbyObj = df.groupby([‘A’, ‘B’]) ; groupbyObj.apply() 跟 groupbyObj.agg() 差異為何? result = groupbyObj .apply( function(df) -> Series ) ; result_agg = groupbyObj .agg( [‘mean’, ‘std’] ) ; aggfunc(Series) -> float](https://i1.wp.com/savingking.com.tw/wp-content/uploads/2023/03/20230327140158_46.png?quality=90&zoom=2&ssl=1&resize=350%2C233)


![Python提取2D array的一部份資料; import numpy; a[1: , 2:] ; a[1:-1 , 2:-1] Python提取2D array的一部份資料; import numpy; a[1: , 2:] ; a[1:-1 , 2:-1]](https://i2.wp.com/savingking.com.tw/wp-content/uploads/2022/09/20220906122441_97.png?quality=90&zoom=2&ssl=1&resize=350%2C233)



近期留言