我正在尝试生成由一些硬编码字符串组成的 word_cloud 的 svg(到目前为止,稍后这些字符串将动态生成)。下面是生成word_cloud的Python代码:
from os import path
from wordcloud import WordCloud
d = path.dirname(__file__)
# Read the whole text.
#text = open(path.join(d, 'test.txt')).read()
mytext = ['hello, hi, ibm, pune, hola']
# Generate a word cloud image
wordcloud = WordCloud().generate(text)
import svgwrite
# Display the generated image:
# the matplotlib way:
import matplotlib.pyplot as plt
plt.imshow(wordcloud, interpolation='bilinear')
plt.axis("off")
Run Code Online (Sandbox Code Playgroud)
现在,我不想使用 plt.show(),而是想将 wordcloud 变量传递给 svgwrite 方法,如下所示:
svg_document = svgwrite.Drawing(filename = "test-svgwrite.svg",profile = 'full')
svg_document.add(svg_document.text(wordcloud,
insert = (210, 110)))
svg_document.tostring()
svg_document.save()
Run Code Online (Sandbox Code Playgroud)
然而,这个创建的 SVG …
我正在尝试使用 Intl.DateTimeFormat 并传递语言环境和日期样式、时间样式选项来更新我的 angular 6 应用程序中的日期。在浏览器控制台中尝试时,我能够获得自定义日期,但是一旦我尝试将其集成到我的应用程序中,它就会引发编译错误:Type '{ dateStyle: string; timeStyle: string; }' has no properties in common with type 'DateTimeFormatOptions'.
transformDate() {
const options = { dateStyle: "full", timeStyle: "medium" };
console.log(new Intl.DateTimeFormat('en-US',options).format(this.date));
}
Run Code Online (Sandbox Code Playgroud)