python-如何正确的使用单引号和双引号(十)

撇号位于两个双引号之间,因此Python解释器能够正确地理解这个字符串:

message="One of  Python's strengths is its diverse community."
print(message)

执行结果

One of  Python's strengths is its diverse community.

然而,如果你使用单引号,Python将无法正确地确定字符串的结束位置:

message='One of  Python's strengths is its diverse community.'
print(message)

执行结果

 File "D:/app/workspace/pythonProject/study_python/day1/apostrophe.py", line 4
    message='One of  Python's strengths is its diverse community.'
                            ^
SyntaxError: invalid syntax
posted @ 2022-03-29 23:24  NiceTwocu  阅读(123)  评论(0编辑  收藏  举报