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

An error about stty #140

Open
jiangtianyise opened this issue Jul 23, 2023 · 3 comments
Open

An error about stty #140

jiangtianyise opened this issue Jul 23, 2023 · 3 comments

Comments

@jiangtianyise
Copy link

_, term_width = os.popen('stty size', 'r').read().split()
ValueError: not enough values to unpack (expected 2, got 0) Can you tell me how to fix the problem?

@jiangtianyise jiangtianyise changed the title An error An error about stty Jul 23, 2023
@shreyakjr10
Copy link

indicates that the os.popen('stty size', 'r').read().split() line is not returning the expected output. This is likely because the stty size command did not return the expected result.The stty size command is used to get the size of the terminal window in rows and columns. It should return something like 24 80 to represent a terminal with 24 rows and 80 columns. However, if your terminal or environment does not support the stty size command, it will return an empty string or something different, leading to the error you encountered.

To fix the problem, you can handle cases where the stty size command does not return the expected output. You can do this by using a try-except block to catch the error and provide a default value for term_width and term_height. Here's an example of how to do it:

**
import os

try:
term_height, term_width = os.popen('stty size', 'r').read().split()
except ValueError:
# Handle the case where 'stty size' did not return the expected result
term_height = 24 # Provide a default value
term_width = 80 # Provide a default value

**

@jiangtianyise
Copy link
Author

Thank you very much,I have fixed the issue

@yichangjianduan
Copy link

非常感谢,我已经解决了这个问题

请问怎么解决的呀 我也是有这个问题

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

3 participants