我想做这样的事......
def helloWorld(): print "Hello world!" str.helloWorld = helloWorld "foo".helloWorld()
哪个会打印出"Hello world!"
编辑:请参阅我可以为内置Python类型添加自定义方法/属性吗?
python string polymorphism attributes
attributes ×1
polymorphism ×1
python ×1
string ×1