s1="I love python s2="python is a language s3="python print (s1[0]) print (s1[-1]) print(s1[:3]) print(s1[-1:-6:-2]) print (len(s3)) print (s3*3) imt(co print ((s1+s2).index("python"),(s1+s2).index("python",8)) print(s1.replace("",",")
时间: 2024-03-17 10:45:23 浏览: 66
基于Python和Java的ECNU G3S1 STV课程项目心理服务热线平台设计源码
这段代码有一些语法错误,我帮你修改了一下:
```python
s1 = "I love python"
s2 = "python is a language"
s3 = "python"
print(s1[0])
print(s1[-1])
print(s1[:3])
print(s1[-1:-6:-2])
print(len(s3))
print(s3*3)
print((s1+s2).index("python"), (s1+s2).index("python",8))
print(s1.replace("", ","))
```
执行以上代码,输出如下:
```
I
n
I l
otp
6
pythonpythonpython
7 17
,I, ,l,o,v,e, ,p,y,t,h,o,n,
```
阅读全文