我试图重载str操作,以便在执行str(string)操作时保留引号。你知道吗
例如:
str(“测试”)
返回测试
我要它返回“测试”
这是我写的,任何帮助都将不胜感激!你知道吗
class Action(MalmoAgent):
def __init__(self, command = '', value = 0):
self.__command = command
self.__value = value
def __str__(self):
return ' " ' + self + ' " '
Tags:
只是格式化你的字符串
使用
repr()
,这显然不是实际的字符串。你知道吗输出
相关问题 更多 >
编程相关推荐