#转载请留言联系 字符串合并 + var str1="chi"; var str2="chung"; console.log(str1+str2) 输出:chichung 把字符串转换城整数[parseInt]或者小数[parseFloat] var num1="100元"; var num2="1.23"; console.log(parseInt(num1)) console.log(parseFloat(num2)) 输…
字符串格式化 %s 可以接收任何值, %d只能接收整形 .其他类型报错 msg ='i am %s my body' %'ales' print(msg) #i am ales my body msg ='i am %s my body is %s' %('alex','xiaoming') #穿多个值加括号 print(msg) #i am alex my body is xiaoming 打印浮点数 tpl = "percent %f" %99.978979934 print(tp…
一,%字符串格式化 1,使用%s 后面一一对应输入对应的字符串,%s可以接受任何参数 print ("I am %s hobby is zhangsan"%'lishi') print ("I am %s hobby is %s"%('lishi','zhangsan')) I am lishi hobby is zhangsanI am lishi hobby is zhangsan 2,%d只能接受数字 msg = "I am %s my age is…