python 的字符串切片

Slicing Strings for python

Write a function slice_from(string, start, end) which returns the characters in string from index start up to, but not including, index end.

我的代码中有这个:

part = s[1:]
print(part)

我的工作计算机上没有安装 python,所以我无法对其进行测试,但这应该可以:

def slice_from(string, start, end):
    returnVal = "";
    for x in range (start, end -1):
        returnVal += string [x];
    return returnVal;

此外,阅读更多内容可能会有所帮助 Python or learning Python online for free at someplace like CodeAcademy