我正在构造一个句子插入到wordxml模板中。下面是我的python2.7代码
#Create a list using a function that returns a comma formatted list of dealers
if len(myList) > 0:
if len(myList) > 1:
testText = list_format(myList) + " dealers."
else:
myText = myList[0] + " dealer."
#Contruct sentence
#myBlurb = "<w:cr/><w:r><w:rPr><w:b/></w:rPr><w:t>My Favorite Cars - </w:t></w:r><w:r><w:t> My favorite cars are available at </w:t></w:r>" + myText + "<w:cr/>"
myBlurb = "<w:cr/>My Favorite Cars - My favorite cars are available at " + myText + "<w:cr/>"
else:
myBlurb = ""
如果列表存在(不等于0),则
我正在尝试获得以下输出:
我最喜欢的车-我最喜欢的车可以在(经销商列表)经销商处买到。你知道吗
这条线上下各有一条新线。前三个字和破折号是粗体的。其他的词都不是粗体的。你知道吗
此操作有效,但不包含粗体文本
myBlurb = "<w:cr/>My Favorite Cars - My favorite cars are available at " + myText + "<w:cr/>"
但当我尝试大胆,它炸弹。它似乎不喜欢这些(+ myText + "<w:cr/>")
(单独或一起)附加在末尾。你知道吗
这行不通
myBlurb = "<w:cr/><w:r><w:rPr><w:b/></w:rPr><w:t>My Favorite Cars - </w:t></w:r><w:r><w:t> My favorite cars are available at </w:t></w:r>" + myText + "<w:cr/
我错过了什么?你知道吗
如果您详细描述“这不起作用”,这总是有帮助的,但我认为这就是您所缺少的(为了清楚起见,只需要整个字符串末尾的代码):
myText
的处理方式应该与要写入文档的静态运行方式相同—它需要声明为包含文本的运行方式。你知道吗相关问题 更多 >
编程相关推荐