# 例子:target='www.163.com'print(target.find('163'))if target.find('263')==-1: print('263不存在于字符串'+target+'中')
运行:
C:\Users\horn1\Desktop\python\7>python find.py4263不存在于字符串www.163.com中
当然,如果仅仅是字符串里是否存在子串的话,使用 in 和 not in 操作符更好。
本文共 227 字,大约阅读时间需要 1 分钟。
# 例子:target='www.163.com'print(target.find('163'))if target.find('263')==-1: print('263不存在于字符串'+target+'中')
运行:
C:\Users\horn1\Desktop\python\7>python find.py4263不存在于字符串www.163.com中
当然,如果仅仅是字符串里是否存在子串的话,使用 in 和 not in 操作符更好。
转载地址:http://zcxyl.baihongyu.com/