使用if判断字符串的长度是否等于10,根据结果进行不同的输出

string1='123456789'
print(len(string1)) # 使用len()计算字符串长度
 if not len(string1) ==10:
    print('字符串的长度不为10')
else:
    print("字符串的长度等于10")

使用if判断字符串的长度是否等于10,根据结果进行不同的输出

原文地址:https://www.cnblogs.com/qsmyjz/p/11994812.html