Skip to content

第11课 字符串is运算错误 #59

@ghost

Description

第11课
s1 = 'hello world'
s2 = 'hello world'
s3 = s2

比较字符串的内容

print(s1 == s2, s2 == s3) # True True

比较字符串的内存地址

print(s1 is s2, s2 is s3) # False True

s1 is s2 会返回true
s1 s2 s3三个对象引用同一个字符串池

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