yn icon indicating copy to clipboard operation
yn copied to clipboard

[BUG]:代码块无法正常执行Python代码,终端中却可以正常执行

Open small-universe opened this issue 3 years ago • 3 comments

Describe the bug

代码块无法正常执行Python代码,终端中却可以正常执行

To Reproduce

Expected behavior

Screenshots

bug

Desktop (please complete the following information):

  • Version: [3.30.1]
  • OS: [Windows10]
  • Browser [e.g. chrome, safari]
  • Python:3.8.10

Additional context

small-universe avatar May 17 '22 11:05 small-universe

我的设备上没能复现。如果方便,可以加项目下面微信详细沟通一下

purocean avatar May 18 '22 01:05 purocean

运行 使用的是python3: https://github.com/purocean/yn/blob/4cfd1acf0fa5de7f80f8e4129686a84a4b4c97bf/src/main/server/run.ts#L31

在终端中运行 使用的是 python: https://github.com/purocean/yn/blob/4cfd1acf0fa5de7f80f8e4129686a84a4b4c97bf/src/renderer/components/Xterm.vue#L138

Windows 上应该没有 python3.exe, 在 Linux 上 python 默认是符号链接到 python2.7。需要把这两种运行统一起来。

huangqinjin avatar May 21 '22 04:05 huangqinjin

应该是 @huangqinjin 这位老铁说的这个原因 @purocean

small-universe avatar May 24 '22 01:05 small-universe

新的代码运行机制可以自定义命令了

purocean avatar Sep 21 '22 21:09 purocean

python在执行代码时如果有缩进报错,但是在终端可以正常运行:

image

代码块如下:

# --run--

def quick_sort(arr, i, j):
    if i < j:
        idx = get_index(arr, i, j)
        quick_sort(arr, i, idx)
        quick_sort(arr, idx + 1, j)

def get_index(arr, i, j): 
    tmp = arr[i]
    while i < j and tmp <= arr[j]:
        j -= 1
    arr[i] = arr[j]
    while i < j and arr[i] <= tmp:
        i += 1
    arr[j] = arr[i]
    arr[i] = tmp 
    return i

arr = [3,2,1,8,4,14]
quick_sort(arr, 0, 5)
print(arr)
```

qq85715512 avatar Jan 24 '24 07:01 qq85715512