我有一個文本文件newfile.txt數組,它包含以下信息:閱讀文本文件轉換成使用Python
http://filefirst.txt
http://filesecond.txt
http://filethird.txt
我應該如何使用Python這樣
line[0] = http://filefirst.txt
line[1] = http://filesecond.txt
...
讀取這個文件等也我想閱讀這個數組變量在Android的活動使用意圖和捆綁。
這樣的:
bundle = getIntent().getExtras();
var1 = bundle.tostring();
var1
應該等於http://filefirst.txt
我應該如何去這樣做呢?
我寫python腳本是這樣的:
f = open('newfile.txt')
for line in iter(f):
extravalue = {}
extravalue['URIVALUE']=line
print(line)
print("value")
MonkeyRunner.sleep(10)
device.startActivity(component=runComponent, extras=extravalue)
device.touch(10,350, 'DOWN_AND_UP')
f.close()
現在我想在另一個活動閱讀演員。 我做這樣的:
Intent intent = getIntent();
Bundle bundle = intent.getExtras();
String uri = null;
if (bundle != null && (uri = bundle.getString("URIVALUE")) != null)
String[] path = uri.split(",");
在機器人我想讀使得路徑[0] =行[0],路徑[1] =行[1]。 目前發生的情況是它只存儲txt文件的最後一行。
如何根據我的要求修改上面的代碼。
問候 Mayank
請正確格式化問題主體,不要混合使用代碼和文本。 –