小编thi*_*uan的帖子

swift:如何删除特定字符?

一个字符串,如! !! 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

string swift swift2

6
推荐指数
3
解决办法
9686
查看次数

re.search().TypeError: 不能在类似字节的对象上使用字符串模式

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”,我该怎么办?谢谢!

python python-3.x

5
推荐指数
2
解决办法
1万
查看次数

标签 统计

python ×1

python-3.x ×1

string ×1

swift ×1

swift2 ×1