這是三個情景我能想到的解釋是:
這裏文本和三重引號左對齊
檢查輸出中,這裏的文本存儲,並沒有在每個段落的開頭一個空格打印。
let textSample1 = """
Test 1: Hello how are you welcome to the test
something else is written here
that's enough said
"""
print(textSample1)
這裏文本具有間距在開始時,但在三重引號中的左對齊
檢查輸出中,這裏的文本存儲,並在每個段落,因爲的開頭用空格打印肚子在左邊引號,他們考慮了段落中的那些空格。
let textSample2 = """
Test 2: Hello how are you welcome to the test
something else is written here
that's enough said
"""
print(textSample2)
這裏文本具有間距在開始時和三重引號也被隔開,
檢查輸出中匹配的文本,這裏的文本存儲,並在開始時無空格打印儘管我們有把空間在beginging,這是因爲三引號處於同一水平文本,而不是空間的地方,這樣他們的空間將被忽略。我發現這是方便當你想多行文本存儲代碼,但想希望保持一些代碼其他用途這間格式化。
let textSample3 = """
Test 3: Hello how are you welcome to the test
something else is written here
that's enough said
"""
print(textSample3)
輸出:
Test 1: Hello how are you welcome to the test
something else is written here
that's enough said
Test 2: Hello how are you welcome to the test
something else is written here
that's enough said
Test 3: Hello how are you welcome to the test
something else is written here
that's enough said
我強烈建議開啓* Xcode的操場*和這個東西玩耍......你可能會驚訝你發現什麼;) –