python如何循环abc
时间: 2023-11-29 22:46:28 浏览: 56
python for循环
以下是两种Python循环abc的方法:
1. 使用for循环遍历字符串
```python
s = 'abc'
for c in s:
print(c)
```
输出:
```
a
b
c
```
2. 使用while循环和索引遍历字符串
```python
s = 'abc'
i = 0
while i < len(s):
print(s[i])
i += 1
```
输出:
```
a
b
c
```
阅读全文