标签:int __iter__ 北京 16px print 内存 __next__ next 获取
s = "我爱北京天安?"
c = s.__iter__() # 获取迭代器
# print(c) # 打印迭代器的地址
# print(c.__next__()) # 打印迭代器中的下一个
# print(c.__next__())
# print(c.__next__())
# print(c.__next__())
# print(c.__next__())
# print(c.__next__())
# print(c.__next__())
# 所以迭代器操作print(c.__next__())的最!大!好!处!可以一个一个输出,不写就不输出
for i in s:
print(i) # for 遍历一下子全出来了,会占内存
标签:int __iter__ 北京 16px print 内存 __next__ next 获取
原文地址:https://www.cnblogs.com/jack20181017/p/9893294.html