使用此代码,我的输出不是字符串列表,而是实例。我是否重新编写LineCount类以允许此类行为?
line_count =[]
class LineCount:
def __init__(self, x):
self.x = x
def set_x(self, x):
self.x = x
def get_x(self):
return self.x
# add a value
line_count.append(LineCount(1))
# print list - does not print our string values
print line_count
# [<__main__.LineCount instance at 0x1031d53f8>]
答案 0 :(得分:1)
您可以更改print语句,使用list comprehesion为列表中的每个元素调用<xsl:variable name="DeliveryOptions>
<xsl:for-each select="DeliveryMethods/DeliveryMethod">
<xsl:value-of select="DeliveryMethod"/>
<xsl:if test="position() != last()">
<xsl:text>,</xsl:text>
</xsl:if>
</xsl:for-each>
</xsl-variable>
函数。
get_x