python学习之认识字符串
生活随笔
收集整理的這篇文章主要介紹了
python学习之认识字符串
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1.打印字符串
>>> print ("hello world") hello world?
?
2.使用“/"進行符號轉義
>>> print ("hello"world") File "<stdin>", line 1 print ("hello"world") ^ SyntaxError: invalid syntax 加“\”符號進行轉義 >>> print ("hello\"world")?
?
3.通過“+”號將字符串連接起來
>>> print ("hello"+" "+"world") hello world?
4.字符串還可以使用乘號
>>> print ("hello"*3) hellohellohello?5.字符串變量
name="Jasper" print("我的名字叫",name) print("%s是我的名字"%name) #變量在結尾直接用逗號隔開,變量在前面或者中間任意位置需要加字符串?
轉載于:https://www.cnblogs.com/shansongxian/p/6037595.html
總結
以上是生活随笔為你收集整理的python学习之认识字符串的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: JavaScript作用域闭包简述
- 下一篇: c# 数据库连接