gpt4 book ai didi

python - 在 Python 中打印到控制台时如何阻止 CLion 在字符串中自动换行

转载 作者:行者123 更新时间:2023-12-05 04:52:46 41 4
gpt4 key购买 nike

令人惊讶的是,我没有找到这个看似非常普遍的问题的答案。在 Python 中,当我向 CLion Console 打印内容时当打印的文本超过 80 个字符时,将插入一个自动 line break。在十六进制中,我可以看到在 Windows 上插入的符号是 carriage return (0D 0A)。我怎样才能阻止这种情况发生?

例子:

print("99b17c2b92123eb0ba2a0afb2568d18247fc2b24385a65b8e2da7245bef278f799b17c2b92123eb0ba2a0afb2568d18247fc2b24385a65b8e2da7245bef278f7")

在控制台上它会在 80 个字符后自动插入一个换行符:

Connected to pydev debugger (build 203.7148.70)
99b17c2b92123eb0ba2a0afb2568d18247fc2b24385a65b8e2da7245bef278f799b17c2b92123eb0
ba2a0afb2568d18247fc2b24385a65b8e2da7245bef278f7

我只想像下面这样不加修改地打印它:

Connected to pydev debugger (build 203.7148.70)
99b17c2b92123eb0ba2a0afb2568d18247fc2b24385a65b8e2da7245bef278f799b17c2b92123eb0ba2a0afb2568d18247fc2b24385a65b8e2da7245bef278f7

最佳答案

事实证明,这是一个尚未解决的 CLion 错误。但是,已发布解决方案here :

  • go to Help | Edit Custom VM Options
  • when asked to create .vmoption file press OK
  • add -Dwin.pty.cols=120 (the number here is for console output width) restart CLion You might want to use this becauserun.processes.with.pty can be useful for an output of C/C++applications.

关于python - 在 Python 中打印到控制台时如何阻止 CLion 在字符串中自动换行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66398076/

41 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com