Comments (2)
import os
import nbconvert
from future import print function
folders = ['01-python-tools',
'02-python-essentials',
'03-numpy',
'04-scipy',
'05-advanced-python',
'06-matplotlib',
'07-interfacing-with-other-languages',
'08-object-oriented-programming',
'09-theano',
'10-something-interesting',
'11-useful-tools',
'12-pandas'
]
mdtxt = open("README.md", encoding="utf8").read()
i = 0
for folder in folders:
for file in os.listdir(folder):
if file.endswith(".png"):
open(file.replace(".png", "temp.png"), "wb").write(open(os.path.join(folder, file), "rb").read())
if not file.endswith(".ipynb"):
continue
i += 1
path = os.path.join(folder, file)
print(path)
converted = nbconvert.export(nbconvert.MarkdownExporter, path)
markdown = converted[0].replace(".png", "temp.png")
pics = converted[1]["outputs"]
for pic_name in pics:
picpath = pic_name.replace(".png", "temp.png")
if (os.path.exists(picpath)):
markdown.replace(picpath, picpath.replace("temp.png", str(i) + "temp.png"))
picpath = picpath.replace("temp.png", str(i) + "temp.png")
with open(picpath, "wb") as p:
p.write(pics[pic_name])
mdtxt += markdown
open("final.md", "w", encoding="utf8").write(mdtxt)
# open Atom markdown-preview and save as html
# open html in chrome and print to pdf
# or other method to convert md to pdf
os.remove("final.md")
for file in os.listdir("."):
if file.endswith("temp.png"):
os.remove(file)
from notes-python.
thx! it works. But in final.md, it have lots of lines of "hello world", so I delete it.
I used vscode extension "Markdown PDF" to convert markdown to pdf
from notes-python.
Related Issues (17)
- 拼写小错误 HOT 2
- 05.01打不开 HOT 1
- 04.09公式输入错误
- Translate these notebooks into English HOT 2
- Update HOT 1
- typo HOT 1
- url unavailable in 02.01-a-tour-of-python.ipynb
- 01.01-python-overview.ipynb
- generate-static-files.py无法转换html和.py
- Python
- python
- 在windows下生成静态文件会报错 HOT 1
- list和tuple的遍历速度问题 HOT 2
- How to use notes-python HOT 1
- convert to Python3 and translate to traditional chinese base on it
- 运行python generate_static_files.py 命令 ,希望生成文件报错,报错 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from notes-python.