用python编写一个简单的小程序:将文字对应的索引打印出来。

test=input('>>>')
print(test)
l=len(test)
print(l)
r=range(l)
for item in r:
    print(item,test[item])

以上为了练习步骤繁琐,下面程序比较简单。

test=input('>>>')
for item in range(len(test)):
    print(item,test[item])

其实两个程序功能原理完全一样,但是对于新手来说,第二个明显难读一点,所以说读程序是明白缘由逐步进行。

相关文章:

  • 2022-12-23
  • 2022-02-22
  • 2021-07-28
  • 2021-11-01
  • 2021-08-26
  • 2021-12-08
  • 2022-12-23
猜你喜欢
  • 2021-06-15
  • 2021-12-14
  • 2021-09-01
  • 2022-12-23
  • 2021-11-23
相关资源
相似解决方案