小编tue*_*eda的帖子

为什么 splitlines() 没有给出 Jupyter 中三点的预期结果?

我相信下面的代码

s = '''
...
.o.
...
'''
print(s.splitlines())
Run Code Online (Sandbox Code Playgroud)

应该打印

['', '...', '.o.', '...']
Run Code Online (Sandbox Code Playgroud)

事实上,Python 正常执行时就是这种情况(在 Wandbox 上运行的示例在这里)。

但现实是无情的(一如既往);Google Colaboratory 打印没有“三点”的结果:

我还使用本地安装的 Jupyter(Python 3.7.13、Jupyter Notebook 6.4.12、IPython 7.34.0)尝试了相同的代码,它给出了与 Google Colaboratory 相同的结果。

有谁知道是什么原因导致三点删除?

python string jupyter-notebook

16
推荐指数
3
解决办法
723
查看次数

Markdown 中的脚注:在 Jupyter 和 Google Colab 上

我正在尝试编写一个基于 Jupyter Notebook 的文档,该文档可以在 Binder 和 Google Colaboratory 上运行。

我喜欢脚注习惯用法,它是一个 Markdown/HTML hack,可以在 Jupyter 上正确工作,描述于

https://github.com/jupyter/notebook/issues/1287#issuecomment-451080550

但它在 Google Colaboratory 上不起作用,因为他们不允许在 Markdown 中使用 HTML 标签:

https://colab.research.google.com/notebooks/markdown_guide.ipynb#scrollTo=w86a4I4fmkvD

是否有任何脚注黑客可以在 Jupyter Notebook 和 Google Colaboratory 上工作?

编辑:该习惯用法在 VS Code Jupyter 扩展中也不起作用。

markdown visual-studio-code jupyter-notebook google-colaboratory

10
推荐指数
1
解决办法
6272
查看次数

“*s = 0”被优化掉。可能是 GCC 13 错误吗?或者一些未定义的行为?

对于 GCC 13.2,以下代码的输出取决于优化级别:

#include <ctype.h>
#include <stdio.h>

char *SkipAName(char *s) {
  if (('A' <= *s && *s <= 'Z') || ('a' <= *s && *s <= 'z') || *s == '_' ||
      *s == '$') {
    if (*s == '$') {
      s++;
    }
    while (isalnum(*s)) {
      s++;
    }
    if (*s == '_') {
      s++;
    }
  }
  return s;
}

int TestName(char *name) {
  while (*name) {
    name++;
  }
  return 0;
}

int StrICmp(char *s1, char *s2) {
  while (*s1 && …
Run Code Online (Sandbox Code Playgroud)

c gcc undefined-behavior

9
推荐指数
1
解决办法
374
查看次数