用python读取txt文本,然后逐行进行操作


f = open("test.txt", "r")  
while True:  
    line = f.readline()  
    if line:  
        pass    # do something here 
        line=line.strip()
        p=line.rfind('.')
        filename=line[0:p]
        print "create %s"%line
    else:  
        break
f.close()

用python读取txt文本,然后逐行进行操作

else直到最后一行关闭读取文件


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM