is 和 == 编码

Posted zuiziyouran

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了is 和 == 编码相关的知识,希望对你有一定的参考价值。

is ==

# s = "周杰伦"
# s1 = s
# print(id(s), id(s1))

# lst = [1, 4, 7]
# lst2 = lst
# lst.append("麻花藤")
# print(id(lst), id(lst2))

# print(id(lst), id(lst2))
#
# s1 = "alex"
# s2 = "alex"
# print(id(s1), id(s2)) # 内存地址是一样的
#
# lst1 = [1, 4, 7]
# lst2 = [1, 4, 7]
# lst1.append("马虎疼")
# print(lst1, lst2)
# print(id(lst1), id(lst2))   # 内存地址不一样


# a = 257
# b = 257
# print(id(a), id(b))

# a = "哈哈哈哈哈哈"
# b = "哈哈哈哈哈哈"
# print(a is b)   #
# print(a == b)

# a = [1, 4, 7]
# b = [1, 4, 7]
# print(a is b)   # False 两个对象
# print(a == b)   # True  内容一致

# a = (1, 8, 6)
# b = (1, 8, 6)
# print(a == b)
# print(a is b)

# lst1 = ["周杰伦", 1, 2]
# lst2 = lst1
# print(lst1 is lst2) #
# print(lst1 == lst2)
a = 1024
b = 1024
print(a is b)
print(a == b)

编码

# s = "alex"
# print(s.encode("UTF-8"))
# print(s.encode("GBK"))

s = "哥"
print(s.encode("UTF-8"))    # b‘\xe5\x93\xa5‘
print(s.encode("GBK"))  # b‘\xb8\xe7‘

  

以上是关于is 和 == 编码的主要内容,如果未能解决你的问题,请参考以下文章

add application window with unknown token XXX Unable to add window;is your activity is running?(代码片段

Flutter 报错 DioError [DioErrorType.DEFAULT]: Bad state: Insecure HTTP is not allowed by platform(代码片段

Error: Python executable “H:devpython3.10python.EXE“ is v3.10.0, which is not supported by gyp.(代码片段

Kotlin学习之旅解决错误:kotlin.NotImplementedError: An operation is not implemented: Not yet implemented(代码片段

is == 编码与解码

ElasticSearch学习问题记录——Invalid shift value in prefixCoded bytes (is encoded value really an INT?)(代码片段