1. 简单粗鲁的字符串拼接 1 name = "abc" 2 age = 25 3 info = "the name is "+name +"\nthe age is " + str(age) 4 print(info) 运行结果: 2.% name = "abc" age = 25 info = "the name is %s \nthe age is %s"%(name ,age) print(info
字符串行数Trim()可以去掉字符串前后的空格,如: C# Code string myString = " this is a test "; Console.WriteLine(myString.Trim()); 输出的结果为: 使用字符串的Replace()函数可以去掉字符串中间及前后的空格: C# Code string myString = " this is a test "; Console.WriteLine(myString.Replace
换行的字符串 "This string\nhas two lines" 字符串中使用单引号时应该怎么写 'You\'re right, it can\'t be a quote' 把数字变成字符串并保留两位小数 var n = 123456.789 n.toFixed(0); //"123457" n.toFixed(2); //"123456.79" parseFloat(str)str以非数字开头,则返回NaN parseFloat(str)