How to create a range of numbers with a given increment

后端 未结 6 942
故里飘歌
故里飘歌 2021-01-15 15:26

I want to know whether there is an equivalent statement in lists to do the following. In MATLAB I would do the following

fid = fopen(\'inc.txt\',\'w\')
init          


        
6条回答
  •  我在风中等你
    2021-01-15 15:28

    test.py contains :

    #!/bin/env python                                                                                                                                                                                  
    
    f = open("test.txt","wb")                                                                                                                                                                           
    for i in range(1,50,5):                                                                                                                                                                             
        f.write("%d\n"%i)
    
    f.close()
    

    You can execute

    python test.py

    file test.txt would look like this :

    1
    6
    11
    16
    21
    26
    31
    36
    41
    46
    

提交回复
热议问题