besthand = "AAAAJ"
besthand = str(filter("J".__ne__, besthand))
为什么besthand的类型仍然是过滤对象?我看到你可以使用
besthand = "".join(besthand)
但我不完全理解为什么 str() 不起作用。是因为过滤器对象是可迭代的吗?
附注我知道它几乎是重复的,但我找不到这个问题的具体答案
您应该直接传递给
join
,不要将生成器转换为字符串:
besthand = 'AAAAJ'
besthand = ''.join(filter('J'.__ne__, besthand))