---name: DavIDpassword: DWewwsadasemail: davID@domain.comwebsitename: Website namewebsitePrefix: websiteprefixwebsiteDomain: domain.comaction: create---
我正在使用以下代码:
Listing = os.Listdir(path)for infile in Listing: stream = open(os.path.join(path,infile),'r') docs = yaml.load_all(stream) for doc in docs: for k,v in doc.items(): print k,"->",v print "\n",
由于第二组—我一直都会遇到错误
解决方法 我知道这是一个老问题,但我遇到了同样的问题,并使用了python-frontmatter.以下是向Front事件添加新变量的示例:import frontmatterimport iofrom os.path import basename,splitextimport glob# Where are the files to modifypath = "en/*.markdown"# Loop through all filesfor fname in glob.glob(path): with io.open(fname,'r') as f: # Parse file's front matter post = frontmatter.load(f) if post.get('author') == None: post['author'] = "alex" # Save the modifIEd file newfile = io.open(fname,'w',enCoding='utf8') frontmatter.dump(post,newfile) newfile.close()
资料来源:How to parse frontmatter with python
总结以上是内存溢出为你收集整理的我如何用Python解析’Front Matter’全部内容,希望文章能够帮你解决我如何用Python解析’Front Matter’所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)