Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在Windows简中系统里使用pywebio_battery.run_shell会报错 #2

Closed
LawrenceDon opened this issue Oct 13, 2022 · 1 comment
Closed

Comments

@LawrenceDon
Copy link

output_func(out.decode('utf8'))

在Windows简中系统里使用pywebio_battery.run_shell会报错:

File "xxxxxx\venv\lib\site-packages\pywebio_battery\interaction.py", line 93, in run_shell
output_func(out.decode('utf8'))
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc7 in position 1: invalid continuation byte

需要将pywebio_battery/interaction.py#L117的output_func(out.decode('utf8')) 改为 output_func(out)
然后下面的代码就可以正常运行了

def myFunc(input):
    put_text(input.decode('GBK'))

def main():
    pywebio_battery.run_shell('dir',output_func=myFunc)
@wang0618
Copy link
Member

wang0618 commented Nov 3, 2023

抱歉忘记更新这个issue了,run_shell() 里后来添加了一个 encoding 参数可以用来设置shell输出的编码

@wang0618 wang0618 closed this as completed Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants