Python-从文件中读取字符串,执行操作,读取下一个字符串并执行相同的操作

时间:2015-03-07 11:51:50

标签: python

我是python的新手,我想从文件输入中读取一个字符串,该文本使用adb shell输入文本然后转到下一行读取下一个字符串并使用相同的命令输入下一个字符串然后继续200行

1 个答案:

答案 0 :(得分:0)

我认为这将解决您的问题,请注意使用readlines方法:

your_file = open('path to your file', 'r')  #this will open your file

lines = your_file.readlines()               #this is an array of lines

for line in lines:                          #loop over the lines
    <block of operations>