巴扎黑2016-11-09 16:56:28 0 1 328
main.py
layout_format = {}for filename in os.listdir('mod'): if filename.endswith('py'): for line in open(os.path.join('mod',filename)): eval(line)print(layout_format)exit()
mod/md.py
markdown_template = "# %(title)s\r\nAuthor: %(author)s\r\nCreate Date: %(created_time)s\r\nLast Update: %(updated_time)s\r\n\r\n%(content)s\r\n"def markdown(self): return markdown_template % self layout_format['md'] = markdown
然而执行出错。。。我想问下,一般python中怎么挂载自己写的子模块呢?
面对疾风吧 2016-11-09 16:56:431楼
layout_format = {}
for filename in os.listdir('mod'):
if filename.endswith('py'):
exec(open(os.path.join('mod',filename)).read())
print(layout_format)
exit()
赞 +0添加回复