我只是想知道是否有任何方法从另一个字符串中删除字符串?像这样的东西:
class String
def remove(s)
self[s.length, self.length - s.length]
end
end
Run Code Online (Sandbox Code Playgroud) 我有一些简单的python代码搜索文件中的字符串,例如path=c:\path,c:\path可能会有所不同.目前的代码是:
def find_path(i_file):
lines = open(i_file).readlines()
for line in lines:
if line.startswith("Path="):
return # what to do here in order to get line content after "Path=" ?
Run Code Online (Sandbox Code Playgroud)
之后获取字符串文本的简单方法是什么Path=?有没有简单的方法,没有封闭,反射或其他深奥的东西?
我想从字符串中删除第一个字符.有这样的功能吗?
>>> a = "BarackObama"
>>> print myfunction(4,a)
ckObama
>>> b = "The world is mine"
>>> print myfunction(6,b)
rld is mine
Run Code Online (Sandbox Code Playgroud)