TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

How do I edit a jupyter notebook ipynb file with python?

1 点作者 bashit超过 6 年前
I wrote a simple note taking application that automates a few things for me when writing notes in markdown style. I can share the gitlab link if need be but perhaps a small description of my problem might be enough...<p>My python application which is very dumb and simple (does what I want) accomplishes a few simple tasks like...<p>* Inserting a markdown style timestamp for each new entry which links to a table of contents section name<p>* Logging complex commands from your bash_history at the end of the day<p>* Automatically archiving notes in a file using a markdown style table of contents<p>* Automatically syncing your notes (using git) with a remote repo on a hosting service like GitHub.<p>This all works fine if I&#x27;m taking notes using a simple <i>.md (markdown) file. However, if I want automate this in the same way with a jupyter notebook ipynb file it becomes extremely more complicated. The ipynb file looks like it&#x27;s in a json&#x27;ish format where some of it looks enrypted and apparently i need to have a notebook server running to open it??<p>Much of my text that isn&#x27;t code in my personal jupyter notebook is formatted in markdown. I have a markdown style table of contents very similar to how I mentioned above. Therefore, it would really be nice if I could open a ipynb file like i do with python, sort it, write a line of text to it. How do I accomplish this?<p>Currently, I do something like the following when I want to insert some text into a </i>.md (markdown) file. Which is simple...<p>with open(somefile, &#x27;r&#x27;) as f:<p>lines = f.readlines()<p>lines.insert(lineNumberToInsertAt, someText)<p>with open(somefile, &#x27;w&#x27;) as f:<p>f.writelines(lines)<p>I can&#x27;t just open a ipynb file like this and write to it so how can I accomplish this?<p>Also I&#x27;m new to this site and noticed that there are some links that say &quot;Ask HN: Some question&quot;. How do I appropriately post questions versus clogging up the main page which is more for articles?

1 comment

suff超过 6 年前
Install PyCharm then pip (or pip3) install jupyter.
评论 #18593982 未加载