#比较代码一
i=0
string='你好啊程序员'
while i<len(string):
    print(i)
    i+=1
#比较代码二
i=0
string='你好啊程序员'
lenth=len(string)
while i<lenth:
    print(i)
    i+=1
总结:方法一需要调用5次len函数,效率低。

相关文章:

  • 2021-08-21
  • 2021-12-09
  • 2022-12-23
  • 2021-04-04
  • 2021-11-10
  • 2021-07-08
  • 2021-09-04
  • 2022-03-03
猜你喜欢
  • 2021-11-29
  • 2021-04-15
  • 2022-02-10
  • 2022-01-24
  • 2022-02-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案