标签: newline

PHP:如何在识别空格时插入<br>?

我有一系列坐标(lat1,long1 lat2,long2 lat3,long3 ...)

121.01953125,14.6893901824952 121.019706726075,14.6893205642702 121.019889831543,14.6891403198242 121.020111083984,14.688931465149 121.020446777344,14.6887502670288 121.020835876465,14.6887207031249

我想做的是每当识别/检测到空间时输入换行符或'br',它就变成......

121.01953125,14.6893901824952 
121.019706726075,14.6893205642702 
121.019889831543,14.6891403198242 
121.020111083984,14.688931465149 
121.020446777344,14.6887502670288 
121.020835876465,14.6887207031249
Run Code Online (Sandbox Code Playgroud)

关于如何做到这一点的任何想法?先感谢您.

编辑:我尝试了他们建议的解决方案,但它不起作用.

echo str_replace(" ","<br />",$string);
Run Code Online (Sandbox Code Playgroud)

我的字符串来自kml文件,当我回显字符串时,它就像我上面所说的那样.我正在使用以下代码来解析文件.

$string = $placemark->MultiGeometry->Polygon->outerBoundaryIs->LinearRing->coordinates;
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助.

php whitespace newline line-breaks

-3
推荐指数
1
解决办法
4644
查看次数

ValueError:long()的基数为10的无效文字:''

我如何让它工作?

n = 1234
f = open("file", "r")
while True:
 x=f.readline()
 print "*********************"
 print n%(long(x))
 if n%(long(x))==0:
   print x
else:
 print "..."
Run Code Online (Sandbox Code Playgroud)

我是python中的菜鸟,我收到一个我不明白的错误.我究竟做错了什么?

ValueError: invalid literal for long() with base 10: ''
Run Code Online (Sandbox Code Playgroud)

python newline strip

-3
推荐指数
1
解决办法
2万
查看次数

在字符串中的javascript代码中删除新行

我在javascript文件的源代码中有一个带有换行符的字符串,如下所示:

var str = 'new
           line';
Run Code Online (Sandbox Code Playgroud)

现在,我想删除代码中的换行符。我对此一无所获,我不断了解\n\r

提前致谢!

javascript newline

-3
推荐指数
1
解决办法
6928
查看次数

如何在Android中创建新行?

我正在开发一个android项目.我想使用创建一个新段落/n.但我没有得到预期的结果.有没有其他方法来创建一个新的线?

我的代码如下

tv.setText("Some of the symptoms of cataract include:/n1.Cloudy, blurry or foggy vision/n2. Development of short-sightedness in older people/n3. Seeing colors differently./n3. Problems with glare during the day or night/n4. Double vision/n5. Sudden changes in prescription of glasses");
Run Code Online (Sandbox Code Playgroud)

android newline

-4
推荐指数
2
解决办法
88
查看次数

python中\n的替代是什么?

我想在python中打印以下输出:

 99 buckets of bits on the bus.
 99 buckets of bits.
 Take one down, short it to ground.
 98 buckets of bits on the bus.
Run Code Online (Sandbox Code Playgroud)

使用单个打印命令,中间没有"\n"字符.如何才能做到这一点?

python newline end-of-line

-4
推荐指数
1
解决办法
1434
查看次数

有没有一种方法可以比一次循环一个字符更快地查找“\n”字符?

查看计算行数时的示例实现wc.c,它循环遍历文件,一次一个字符并累加 '\n' 以计算换行数:

#define COUNT(c)       \
      ccount++;        \
      if ((c) == '\n') \
        lcount++;
Run Code Online (Sandbox Code Playgroud)
  • 有没有办法只在文件中查找“\n”并继续跳转到换行符并进行计数?

  • 寻找 '\n' 与一次读取一个字符直到我们看到 '\n' 并对其进行计数是一样的吗?

c++ string newline count wc

-4
推荐指数
1
解决办法
350
查看次数

String.equals()方法不匹配"\n"字符

所以我对String类的equals()方法有问题.我正在尝试检查以确保用户输入不仅仅是一个新行字符("\n"),但每当我比较只是换行符的用户输入时,它总是返回false.这是代码:

command = kb.nextline();
if(!command.equals("\n"))
{
    performProcess(command);
}
Run Code Online (Sandbox Code Playgroud)

其中"kb"是扫描仪.有任何想法吗?

java newline equals

-5
推荐指数
1
解决办法
1512
查看次数

如何写文件原样?

我有一串这样的代码:

<?php
echo "Hello World";
?>
Run Code Online (Sandbox Code Playgroud)

现在,我想把它写成一个php文件就像它一样.我的意思是我想用新的行字符编写这段代码.所以代码以上面的方式存储.那么,我该怎么做呢?

我曾尝试使用文件附加fwrite,但是他们在一个连续的行中编写代码,我想要的是将它分成3行.

  • 在第一行 - <?php
  • 在第二行 - echo "Hello world";
  • 在第三行 - ?>

但我想通过只使用一行代码来完成它,就像下面的那样.

$file = 'people.php';
// The new person to add to the file
$person = "John Smith\n";
// Write the contents to the file, 
// using the FILE_APPEND flag to append the content to the end of the file
// and the LOCK_EX flag to prevent anyone else writing to the file at …
Run Code Online (Sandbox Code Playgroud)

php newline

-6
推荐指数
1
解决办法
424
查看次数

标签 统计

newline ×8

php ×2

python ×2

android ×1

c++ ×1

count ×1

end-of-line ×1

equals ×1

java ×1

javascript ×1

line-breaks ×1

string ×1

strip ×1

wc ×1

whitespace ×1