IOS plist讀取寫入

2021-07-11 07:01:56 字數 857 閱讀 8274

new_file plist property list.plist

讀取本地plist

nsstring *plistpath = [[nsbundle mainbundle] pathforresource:@"property list" oftype:@"plist"];

nsmutabledictionary *data = [[nsmutabledictionary alloc] initwithcontentsoffile:plistpath];

nslog(@"%@", data);//直接列印資料。

在模擬器中新增鍵值對

//新增一項內容

[data setobject:@"add some content" forkey:@"c_key"];

//獲取應用程式沙盒的documents目錄

nsarray *paths=nssearchpathfordirectoriesindomains(nsdocumentdirectory,nsuserdomainmask,yes);

nsstring *plistpath1 = [paths objectatindex:0];

//得到完整的檔名

//輸入寫入

[data writetofile:filename atomically:yes];

//那怎麼證明我的資料寫入了呢?讀出來看看

nsmutabledictionary *data1 = [[nsmutabledictionary alloc] initwithcontentsoffile:filename];

nslog(@"%@", data1);

寫入 讀取檔案

file類下面的方法 string str file.readalltext aa.txt system.text.encoding.getencoding utf 8 讀取檔案 console.writeline str console.read filestream類下面的方法 在當前目錄建立乙...

讀取寫入檔案

file1 open c users administrator desktop text 成績.txt w encoding gbk file1.write 羅恩 23 35 44 哈利 60 77 68 88 90 馬赫 97 99 89 91 95 99 媽富爾 100 85 90 file1...

python word excel 讀取 寫入

import docx import os import numpy as np import pandas as pd import re path r d hard way 定義word檔案路 doc docx.document path ceshi.docx 讀入word文件 len doc....