V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
V2EX  ›  XIVN1987  ›  全部回复第 15 页 / 共 42 页
回复总数  838
1 ... 11  12  13  14  15  16  17  18  19  20 ... 42  
2021 年 1 月 7 日
回复了 AzureDeer 创建的主题 Python 请问大家,我这一段为啥报错呀
sum_score 不能用全局变量吧,难道你每次调用 get_average()都要累计之前的分数?
那你计算平均分的时候只除以本次调用的科目数,,平均分岂不是越来越高、单调递增了~~~^_^~~~
2021 年 1 月 7 日
回复了 unknowfly 创建的主题 Python 请教一个关于类和实例使用的疑问
我觉得第一种用法和第二种用法的主要区别是:第二种用法强制调用__init__方法,这样类的设计者可以在__init__中做各种初始化和环境检查
2021 年 1 月 5 日
回复了 zxCoder 创建的主题 C 大家写 C 语言除了搞硬件的,还有做什么工作的啊
Gtk 用的 C,,跨平台的 GUI
2021 年 1 月 4 日
回复了 RingSunKaiya 创建的主题 Python Python 中如何直接 import 某个 dll
@dinjufen

说到 boost::python,,那不如试试它的一个轻量级复制品,,

pybind11 is a lightweight header-only library that exposes C++ types in Python and vice versa, mainly to create Python bindings of existing C++ code. Its goals and syntax are similar to the excellent Boost.Python library by David Abrahams: to minimize boilerplate code in traditional extension modules by inferring type information using compile-time introspection.

header-only,没有依赖、简化配置、更易使用,,下面这个帖子里有我的编译方法,可以看到非常简单:

https://www.v2ex.com/t/740805
2021 年 1 月 4 日
回复了 RingSunKaiya 创建的主题 Python Python 中如何直接 import 某个 dll
虽然后缀名是 dll,,但文件内容可能是 pyd,,

毕竟后缀名可以随便改,,不能仅凭后缀名就断定文件内容
虽然在 jupyter notebook 中没有显示“Hello 16 2.30”,但在 jupyter.exe 终端中有显示,,能够验证代码的执行效果,,所以这个问题不算很严重
找到一篇文章,上面说出现这种问题的原因是:
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
2020 年 12 月 30 日
回复了 XIVN1987 创建的主题 Jupyter jupyter 转 markdown 要是能内嵌图片就好了
写了脚本,自动将 jupyter 导出的 markdown 中的

```
![png](output_3_0.png)
```

替换成

```
<img src="data:image/png;base64,iVBO...">
```

代码如下:

``` python
#! python3
import os
import re
import binascii

srcfil = r'C:\Users\WMX\Desktop\pylab\pylab.md'

srcdir = os.path.dirname(srcfil)
dstfil = os.path.join(srcdir, os.path.basename(srcfil).replace('.md', '_emb.md'))

img_base64 = {}
for root, dirs, files in os.walk(srcdir):
for fname in files:
if fname.endswith('.png'):
img_data = open(os.path.join(root, fname), 'rb').read()
img_base64[fname] = f'<img src="data:image/png;base64,{binascii.b2a_base64(img_data, newline=False).decode("latin-1")}">'

content = open(srcfil, 'r', encoding='utf-8').read()
for img in img_base64:
content = re.sub(f'\n!\[png\]\({img}\)\n', f'\n{img_base64[img]}\n', content)

open(dstfil, 'w', encoding='utf-8').write(content)

```
2020 年 12 月 30 日
回复了 XIVN1987 创建的主题 Jupyter jupyter 转 markdown 要是能内嵌图片就好了
2020 年 12 月 30 日
回复了 XIVN1987 创建的主题 Jupyter jupyter 转 markdown 要是能内嵌图片就好了
@neosfung
感谢,,试了下确实支持

之前测试不工作,原来是 jupyter 导出的时候多了两个换行,,为知笔记就不认了,,把换行去掉就可以了

jupyter 导出的是

``` javascript
<img src="data:image/png;base64,iVBO...
"
>
```

改成

``` javascript
<img src="data:image/png;base64,iVBO...">
```

就可以了,,
2020 年 12 月 30 日
回复了 XIVN1987 创建的主题 Jupyter jupyter 转 markdown 要是能内嵌图片就好了
@neosfung
确实,html 输出中通过<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...">语法内嵌了图片

查了下这个语法叫 Data URI scheme,,希望 markdown 也能支持这种用法,,这样笔记会方便很多

感谢指点
js 这个 import .. from ... 很魔性啊,自动补全怎么工作?

是不是先打 form ...,然后在回到行首打 import 啊?
@abersheeran
前者是 pos-only
后者是 kw-only
2020 年 12 月 26 日
回复了 taogen 创建的主题 Linux 2021 年 Linux 发行版推荐?
deepin,界面比较美观
2020 年 12 月 26 日
回复了 fxjson 创建的主题 PHP PHP 越来越靠近编译型语言了
@cmdOptionKana
你说反了吧,,微软搞 typescript 这是在给 js 挖坟啊
你看现在知乎上关于 js 和 ts 的问题下面,,大量的回答都是夸 ts 贬 js 的,都是劝退 js 劝进 ts 的,搞得好像用 js 就落伍了似的,,要是真被他们搞成了就没人用 js 了,,
前面正常写,,后面再处理一步不行吗?
mylist = [
1,
2,
a,
4
]

mylist = [x for x in mylist if x]
2020 年 12 月 24 日
回复了 QGabriel 创建的主题 Python Python 小白提个问题
@QGabriel
index.py 的第一行添加“#! python3”,执行的时候用“py index.py”,,py.exe 会自动根据文件第一行选择用 python2 执行还是用 python3 执行
这样写还有一个好处,双击 index.py 执行的时候系统也能够自动选择正确版本的 python
2020 年 12 月 23 日
回复了 zbianbiaos 创建的主题 C 求高人指点,做单片机还有出路吗
众所周知,做单片机的收入比互联网的差很多,,
如果有机会做互联网的话,尤其是能进大中型的互联网企业,,那不要犹豫,尽管转去
2020 年 12 月 2 日
回复了 secsilm 创建的主题 C++ C++ IDE/editor 推荐
@onecode

vs 安装的时候搞的到处都是,,不像 qtcreator 、clion 这种软件只把文件装到一个指定目录下面去
1 ... 11  12  13  14  15  16  17  18  19  20 ... 42  
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1167 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 27ms · UTC 17:57 · PVG 01:57 · LAX 10:57 · JFK 13:57
♥ Do have faith in what you're doing.