Skip to content

3.1.2. 字符串 End of lines are automatically included in the string 里有翻译错误 #242

@Delhpi

Description

@Delhpi

String literals can span multiple lines. One way is using triple-quotes: """...""" or '''...'''. End of lines are automatically included in the string, but it’s possible to prevent this by adding a \ at the end of the line.
这句话的意思,默认情况下,会有1个 换行 字符包括到那个多行字符串里。但是中文文档里说 加在字符串 行尾,
https://docs.python.org/zh-cn/3.9/tutorial/introduction.html

实际是加在 字符串 开头。
测试代码:
a ="""
Usage: thingy [OPTIONS]
-h Display this usage message
-H hostname Hostname to connect to
"""
print('a变量的长度是',len(a))
print('a变量第一个字符的ASCii是',ord(a[0]))
b="""
Usage: thingy [OPTIONS]
-h Display this usage message
-H hostname Hostname to connect to
"""
print('b变量的长度是',len(b))
print('b变量第一个字符的ASCii是',ord(b[0]))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions