Python使用用户定义的字符串类

Python使用用户定义的字符串类,第1张

Python使用用户定义字符串

这不可能。您尚未覆盖字符串类。

您不能覆盖类。您可以覆盖方法。您所做的是定义一个类,并且仅覆盖其str()方法。

但是你可以做这样的事情…

def overriden_print(x):    print "Overriden in the past!"from __future__ import print_function  # import after the definition of overriden_printprint = overriden_printprint("Hello")

输出:

覆盖过去!



欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5645900.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存