search

Home  >  Q&A  >  body text

python怎么累加变量

   for i in range(0,len(row)):

     strs = i;
     print(strs)
     
     我想要strs 的值是 0,1,2,3  就是一个累加的字符串
PHP中文网PHP中文网2781 days ago704

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-04-18 10:24:31

    s = ''

    for i in range(0,5):

    s += str(i)+','
    

    print(s)

    reply
    0
  • 黄舟

    黄舟2017-04-18 10:24:31

    strs = ','.join([str(_) for _ in range(4)])
    print strs
    

    reply
    0
  • Cancelreply