python之判断字符串以何关键字开头
(str.startswith('关键字') is True:以关键字开头 False:不以关键字开头
还可以指定关键字所处位置:
#!/usr/bin/python
str = "this is string example....wow!!!";
print str.startswith( 'this' );
print str.startswith( 'is', 2, 4 );
print str.startswith( 'this', 2, 4 );

浙公网安备 33010602011771号