问题标签 [trailing-whitespace]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
48 浏览

python - 无法弄清楚如何从我的结果中删除尾随空格

我的代码从数组中找到平衡二叉树的输入。

输出如下所示:178 57 26 157 679 397 898

到目前为止,除了从输出中删除尾随空格之外,我已经能够做所有事情。我必须使用end=" "它在一行中输出,但这意味着最后一个值后面也有一个空格。我尝试使用.rstrip(),但这也不起作用,因为我认为它只适用于字符串。最后我将如何删除这个空格?

0 投票
0 回答
55 浏览

c - how to input /n on a program that uses getchar() (and other confusion)

This is a pretty loosely fitting title I'll admit.

I'm doing an exercise where we are tasked with creating a program that removes trailing whitespace and deletes blank lines. One of the solutions posted online received praise but, when I run the code, it doesn't even seem like it does anything. Here is the solution I'm referring to, with a brief excerpt that I'm confused by

The program specification is ambiguous: does "entirely blank lines"
mean lines that contain no characters other than newline, or does it include lines composed of blanks and tabs followed by newline? The latter interpretation is taken here.

So he's saying that the code should be removing blank lines but I don't think it does, at least not when I run it. And I don't know how you would enter a new line as input because when you press enter it doesn't skip a line, it takes your input and continues to run the program. He goes on to mention "blanks and tabs followed by a newline" but again...what is newline when enter just runs the program? And if you try to leave lines blank just by pressing a tab or space a bunch, the program doesn't delete those lines, it prints out the same blank line, so I really don't know what his program is doing or what he's talking about.

Apart from running the code, I've also stepped through it with the debugger and I find it kind of confusing but I don't even want to get into that until I can figure out what it's even trying to accomplish or why it's being praised when it seemingly doesn't accomplish anything.

0 投票
1 回答
63 浏览

c - 从 .c/.h 源文件中去除尾随空格是否 100% 安全?

我想自动删除 .c 和 .h 文件中的所有尾随空格,以减少导致 git 历史记录中合并冲突的垃圾等。

有什么可以想象的方法可以改变编译阶段的输出吗?或者自动执行此操作是否完全安全?

0 投票
0 回答
42 浏览

react-native - 反应原生文本尾随空格

我有一个简单的Text元素,可以从 json 文件加载数据,并且一切正常,但是当我应用样式“justify”时,我发现 Text 末尾有一个很大的尾随空格,无法删除它。

我尝试修剪{mydata.trim()},它没有工作,或者可能是修剪工作但应用样式调整再次添加尾随空格。

有什么建议么

0 投票
1 回答
18 浏览

html - 网站有一些尾随空格,或溢出

我正在构建一个结合了 flex 和 grid 的投资组合页面。在页面的左侧,有一个大约 8 个像素的小间隙,我的页眉是不均匀的。我试过做 left: -9px; 但这并不能解决问题。我试过隐藏溢出,但我无法滚动。我也尝试过严格地调整布局,但没有改变结果。如何消除左侧的间隙?这被认为是尾随空格还是溢出?