惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Fortinet All Blogs
Attack and Defense Labs
Attack and Defense Labs
V2EX - 技术
V2EX - 技术
O
OpenAI News
S
Secure Thoughts
H
Heimdal Security Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Schneier on Security
Schneier on Security
H
Hacker News: Front Page
S
Security Affairs
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
The Register - Security
The Register - Security
GbyAI
GbyAI
Cloudbric
Cloudbric
MongoDB | Blog
MongoDB | Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
K
Kaspersky official blog
Forbes - Security
Forbes - Security
Y
Y Combinator Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Scott Helme
Scott Helme
Hacker News - Newest:
Hacker News - Newest: "LLM"
The Cloudflare Blog
Recorded Future
Recorded Future
人人都是产品经理
人人都是产品经理
Cyberwarzone
Cyberwarzone
C
CERT Recently Published Vulnerability Notes
Webroot Blog
Webroot Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LangChain Blog
T
Tor Project blog
Microsoft Azure Blog
Microsoft Azure Blog
博客园_首页
Hacker News: Ask HN
Hacker News: Ask HN
Blog — PlanetScale
Blog — PlanetScale
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
Blog RSS Feed
N
News and Events Feed by Topic
阮一峰的网络日志
阮一峰的网络日志
I
Intezer
V
V2EX
T
Tailwind CSS Blog
SecWiki News
SecWiki News
NISL@THU
NISL@THU
C
Check Point Blog

Jupyter

SSL 认证莫名其妙报错了,需要引起警惕吗? - V2EX 这是什么 jupyter 插件,感觉挺酷 - V2EX 现在人工智能专业这么火,大家 jupyter 常用的一些插件和功能是啥? - V2EX pycharm 的里的 jupyternotebook 能断点调试吗? - V2EX Jupyter Notebook 到底是用来干啥的? - V2EX pycharm 里连接远程 jupyter,自动补全怎么搞? - V2EX 单元格如何取消关联 - V2EX jupyter-notebook 内置环境变量问题 - V2EX Jupyter 里有什么插件 / Kernel 可以实现类似 ob-http 的功能 - V2EX 如何计算重复率统计? - V2EX 如何在内网环境从 Windows SSH 访问 Linux 服务器 - V2EX anaconda3 环境下,在 cmd 输入"jupyter lab"显示"Exception: Jupyter command `jupyter-lab` not found." - V2EX jupyter-nbconvert.exe --generate-config 报错 UnicodeEncodeError: 'gbk' - V2EX jupyter 转 markdown 要是能内嵌图片就好了 - V2EX JupyterLab 插件功能小贴士 - V2EX Jupyter 的输出窗口可以同时动态刷新两种图吗? - V2EX 最近整理了一些 Jupyter book 文档 - V2EX jupyter 怎么读 - V2EX 使用 Jupyter notebook 生成柱状图失败,问题出在哪?? - V2EX 求助, Jupyter 已经启动,但是网页无法显示 - V2EX 用 Jupyter 写非 Python 体验如何? - V2EX 写了一些 Jupyter notebook 的扩展插件 - V2EX Supervisor 无法停止 Jupyter Notebook - V2EX Jupyter 上的 Lua 与 torch7 - V2EX
jupyter 中通过 ctypes 调用 printf()时,不显示 printf()打印内容 - V2EX
XIVN1987 · 2020-12-31 · via Jupyter

这是一个创建于 1991 天前的主题,其中的信息可能已经有所发展或是发生改变。

代码:

from ctypes import *

libc = cdll.LoadLibrary('msvcrt.dll')
libc.printf(c_char_p(b'Hello %d %.2f\n'), c_int(16), c_double(2.3))

在标准交互环境中显示内容为:

Hello 16 2.30
14

在 ipython 中,显示内容为:

Hello 16 2.30
Out[31]: 14

在 jupyter 中,显示内容为:

Out[15]: 14

请问在 jupyter 中如何显示“Hello 16 2.30”

XIVN1987

1

XIVN1987      2021 年 1 月 1 日

找到一篇文章,上面说出现这种问题的原因是:
IPython forwards the Python-level sys.stdout and sys.stderr, but it leaves the process-level file descriptors that C code will write to untouched. That means that in a context like this notebook, these functions will print to the terminal, because they are not captured.

文章链接: https://notebook.community/minrk/wurlitzer/Demo

XIVN1987

2

XIVN1987      2021 年 1 月 1 日

虽然在 jupyter notebook 中没有显示“Hello 16 2.30”,但在 jupyter.exe 终端中有显示,,能够验证代码的执行效果,,所以这个问题不算很严重