一个字符串,如! !! yuahl! !,我想删除!和 ,当我像这样的代码
for index in InputName.characters.indices {
if String(InputName[index]) == "" || InputName.substringToIndex(index) == "!" {
InputName.removeAtIndex(index)
}
}
Run Code Online (Sandbox Code Playgroud)
有这个错误"致命错误:下标:subRange扩展过String结束",我该怎么办?THX:D
import urllib.request
import re
f = urllib.request.urlopen('http://www.geekynu.cn/')
html = f.read()
title = re.search('<title>(.*?)</title>', html)
print(title)
#print(title.decode('utf-8')) //I had try to solve by this code.
Run Code Online (Sandbox Code Playgroud)
[python 3.5] 当我使用re.search()阅读网页标题时,出现错误“TypeError: cannot use a string pattern on a bytes-like object”,我该怎么办?谢谢!