在寫測試腳本時,經常有一些需要變動的資料,可以單獨放在ini檔案裡,然後讀取傳遞給
相應的函數,這樣程式操作更靈活。具體的方法介紹如下:
檔案結構:

Cofig.ini内容:
[test1]
ip = 10.10.10.10
[test2]
port = 25566
[test3]
name = www.baidu.com
直接上代碼
輸出的結果:
['test1', 'test2', 'test3']
['ip']
[('ip', '10.10.10.10')]
[('ip', '11.11.1.1'), ('addr', 'shenzhen')]