單雙引號,轉義符

2021-05-27 09:00:02 字數 888 閱讀 6400

1. 雙引號括起來的字串,列印出來也是單引號

>>> "hello world"

'hello world'

2.使用單引號

>>> 'hello world'

'hello world'

3.單雙引號混合使用

>>> "let's go"

"let's go"

>>> '"hello world" she said'

'"hello world" she said'

4.單單,雙雙使用

>>> 'let's go'

file "", line 1

'let's go'

^syntaxerror: invalid syntax

>>> ""hello world" she said"

file "", line 1

""hello world" she said"

^syntaxerror: invalid syntax

5.上記可以用轉義符

>>> 'let\'s say "hello world"'

'let\'s say "hello world"'

6.還可以用拼接實現

>>> "let's say " '"hello world"'

'let\'s say "hello world"'

7. 字串拼接

>>> x = "hello"

>>> y = "world"

>>> x y

file "", line 1

x y^

syntaxerror: invalid syntax

>>> x + y

'helloworld'

>>> 

PHP 界定符( ),單雙引號

三者雙引號 單引號 界定符 比較如下 1 單引號 單引號是不做內容解析的,即原樣輸出,a 123 echo 這是 a 2 雙引號 雙引號會對引號內的內容做解析,a 123 echo 這是 a 3 界定符 主要用於一些大的文字內容,如果中間包含已定義的變數 php也會解析,用於輸出,不用於定義字串 a...

velocity 單引號和雙引號轉義

預設情況下,velocity 通過 set var 為變數賦值時,如果等號右側是用雙引號引起來的字串,則會對字串中的變數進行解析,如 set var1 test1 set var2 test2 var1 var2 將輸出 test2 test1 如果是用單引號引起來的,則不會對引號中的變數進行解析,...

1 5 單引號 雙引號及轉義字元

比如,我們想在螢幕輸出 hello world 我們可以以單引號開頭單引號結尾,或者是雙引號開頭,雙引號結尾 print hello word print hello word 假如我想列印下面這段文字,但是文字裡面有乙個單引號和兩個雙引號 那麼,如果我們在print函式裡面,以單引號開頭,單引號結...