python学习手册 epub从入门到精通

Python学习手册epub是一本用于帮助初学者学习Python编程的电子书,其中包含了Python基础知识、Python脚本编写、Python编程技巧等内容。代码如下:

Python学习手册epub是一本用于帮助初学者学习Python编程的电子书,其中包含了Python基础知识、Python脚本编写、Python编程技巧等内容。代码如下:

import epub

book = epub.EpubBook()

# set metadata

book.set_identifier('python_learning_manual')

book.set_title('Python Learning Manual')

book.set_language('en')

# add chapters

chapter1 = epub.EpubHtml(title='Introduction to Python', file_name='chapter1.xhtml', lang='en')

chapter1.content=u'

Introduction to Python

This chapter will introduce you to the basics of Python programming.

'

book.add_item(chapter1)

# define Table Of Contents

book.toc = (epub.Link('chapter1.xhtml', 'Introduction to Python', 'intro'),

(epub.Section('Python Scripting'),

(epub.Link('chapter2.xhtml','Writing Your First Python Script','scripting'),

epub.Link('chapter3.xhtml','Advanced Python Scripting','advancedscripting')),

(epub.Section('Python Programming Tips'),

(epub.Link('chapter4.xhtml','Debugging Your Code','debugging'),

epub.Link('chapter5.xhtml','Optimizing Your Code','optimizing')))

)

# add default NCX and Nav file

book.add_item(epub.EpubNcx())

book.add_item(epub.EpubNav())

# define CSS style

style = 'BODY {color: white;}'

nav_css = epub.EpubItem(uid="style_nav", file_name="style/nav.css", media_type="text/css", content=style)

# add CSS file

book.add_item(nav_css)

# basic spine

book.spine = ['nav', chapter1]

# write to the file

epub.write_epub('python_learning_manual.epub', book, {})

本站系公益性非盈利分享网址,本文来自用户投稿,不代表边看边学立场,如若转载,请注明出处

(44)
python时区转换:从Python时区转换到其他时区的指南
上一篇
python接口自动化参数化:使用Python接口自动化实现快速参数化
下一篇

相关推荐

发表评论

登录 后才能评论

评论列表(21条)