[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/Lovepython015/Python/master/Article/PythonBasis/python7/2.md [Back]  [Original]

# Python  #

 Python 





iter()  next(), for  next() 



```python
# 1
str1 = 'liangdianshui'
iter1 = iter ( str1 )

# 2list
list1 = [1,2,3,4]
iter2 = iter ( list1 )

# 3tuple() 
tuple1 = ( 1,2,3,4 )
iter3 = iter ( tuple1 )

# for 
for x in iter1 :
    print ( x , end = ' ' )

print('\n------------------------')
 
# next() 
while True :
    try :
        print ( next ( iter3 ) )
    except StopIteration :
        break

```



```txt
l i a n g d i a n s h u i 
------------------------
1
2
3
4
```

Web Proxy Viewer  |  New URL  |  Original Page