多行、双引号、但引号
smoke@smoke-GS70-2PC-Stealth:~/文档/DocumentFile/file/python_script$ vim 多行.py
msg = "hello 1
hello 2
hello 3
"
print(msg)
smoke@smoke-GS70-2PC-Stealth:~/文档/DocumentFile/file/python_script$ python3.8 多行.py
File "多行.py", line 1
msg = "hello 1
^
SyntaxError: EOL while scanning string literal #语法错误,扫描字符串文本时的EOL
smoke@smoke-GS70-2PC-Stealth:~/文档/DocumentFile/file/python_script$ vim 多行.py
msg = '''hello 1
hello 2
hello 3
'''
print(msg)
smoke@smoke-GS70-2PC-Stealth:~/文档/DocumentFile/file/python_script$ python3.8 多行.py
hello 1
hello 2
hello 3
smoke@smoke-GS70-2PC-Stealth:~/文档/DocumentFile/file/python_script$ vim 多行.py
'''hello 1
hello 2
hello 3
'''
print(msg)
smoke@smoke-GS70-2PC-Stealth:~/文档/DocumentFile/file/python_script$ python3.8 多行.py
Traceback (most recent call last):
File "多行.py", line 6, in <module>
print(msg)
NameError: name 'msg' is not defined
smoke@smoke-GS70-2PC-Stealth:~/文档/DocumentFile/file/python_script$ vim 多行.py
msg = "Hello, its me"
print(msg)
smoke@smoke-GS70-2PC-Stealth:~/文档/DocumentFile/file/python_script$ python3.8 多行.py
Hello, its me
smoke@smoke-GS70-2PC-Stealth:~/文档/DocumentFile/file/python_script$ vim 多行.py
msg = 'Hello, its me'
print(msg)
smoke@smoke-GS70-2PC-Stealth:~/文档/DocumentFile/file/python_script$ python3.8 多行.py
Hello, its me #python双引号和但引号意义是一样的
smoke@smoke-GS70-2PC-Stealth:~/文档/DocumentFile/file/python_script$ vim 多行.py
smoke@smoke-GS70-2PC-Stealth:~/文档/DocumentFile/file/python_script$ python3.8 多行.py
File "多行.py", line 1
msg = 'Hello, it's me'
^
SyntaxError: invalid syntax
smoke@smoke-GS70-2PC-Stealth:~/文档/DocumentFile/file/python_script$ vim 多行.py
msg = 'Hello, it"s me'
print(msg)
smoke@smoke-GS70-2PC-Stealth:~/文档/DocumentFile/file/python_script$ python3.8 多行.py
Hello, it"s me
smoke@smoke-GS70-2PC-Stealth:~/文档/DocumentFile/file/python_script$ vim 多行.py
msg = "Hello, it's me"
print(msg)
smoke@smoke-GS70-2PC-Stealth:~/文档/DocumentFile/file/python_script$ python3.8 多行.py
Hello, it's me
smoke@smoke-GS70-2PC-Stealth:~/文档/DocumentFile/file/python_script$ vim 多行.py
msg = '''Hello', it"s me'''
print(msg)
smoke@smoke-GS70-2PC-Stealth:~/文档/DocumentFile/file/python_script$ python3.8 多行.py
Hello', it"s me
浙公网安备 33010602011771号