print(msg.lstrip('*'))#hello*** print(msg.rstrip('*'))#***hello 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 举个栗子(程序交互,如果用户在输入的用户名或者密码时不小心多按了空格,也不会造成错误,可以正常登陆) while True: name=input('user: ').strip() password=input('password: ').stri...
isdecimal:str,unicode num0='4'num1=b'4'#bytesnum2=u'4'#unicode,python3中无需加u就是unicodenum3='四'#中文数字num4='Ⅳ'#罗马数字print(num0.isdecimal())#print(num1.)print(num2.isdecimal())print(num3.isdecimal())print(num4.isdecimal()) isnumeric:str,unicode,中文,罗马 num0='4...
>>> print(s) http://docs.python.org/3/library/turtle.html >>> http://news.gzcc.cn/html/xiaoyuanxinwen/4.html 产生校园新闻的一系列新闻页网址 for i in range(2,231): "http://news.gzcc.cn/html/xiaoyuanxinwen/{}.html".format(i) 练习字符串内建函数:strip,lstrip,rstrip,split,count ...
string.lstrip() #removes whitespace from left string.rstrip() #removes whitespace from right string.split() #splitting words string.split(',') #split words by comma string.count('l') #count how many times l is in the string string.find('Wo') #find the word Wo in the string string....