python出现invalid argument什么意思_Python的一个报错——OSError: [Errno 22] Invalid argument...

一个 Python 脚本有如下获取当前终端行列宽度的一行代码:columns, rows = os.get_terminal_size()

大部分情况是正常的如:./hubble_bench.py --help

hubble_bench.py

Usage:

./hubble_bench.py --issue_type=

Options:

--issue_type= cpu_high_load, bufferpool_too_small, io_high_usage, net_high_usage, high_concurrency, slow_query, meta_lock, deadlock, large_uncommitted, seckill, connection_grow

--thread_min=

--thread_max=

但假如后面接管道就报错了:./hubble_bench.py --help | less

Traceback (most recent call last):

File "./hubble_bench.py", line 40, in

columns, rows = os.get_terminal_size()

OSError: [Errno 22] Invalid argument

后面发现改成用 shutil 来代替 os 模块就可以了:columns, rows = shutil.get_terminal_size()

``

承接Matlab、Python和C++的编程,机器学习、计算机视觉的理论实现及辅导,本科和硕士的均可,咸鱼交易,专业回答请走知乎,详谈请联系QQ号757160542,非诚勿扰。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值