Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何创建一个HTML页面,该页面使用python中的n种不同颜色n次表示Hello World,_Javascript_Python_Html - Fatal编程技术网

Javascript 如何创建一个HTML页面,该页面使用python中的n种不同颜色n次表示Hello World,

Javascript 如何创建一个HTML页面,该页面使用python中的n种不同颜色n次表示Hello World,,javascript,python,html,Javascript,Python,Html,我想创建一个HTML页面,用n种不同的颜色n次说Hello World,其中n是从不同存储库中的配置文件中读取的 并通过python程序生成页面 如果我们可以使用Javascript来显示颜色,那会更有帮助。我能够多次显示hello world,但我不知道如何更改颜色。 以下是我迄今为止编写的代码: import ConfigParser import webbrowser configParser = ConfigParser.RawConfigParser() configPar

我想创建一个HTML页面,用n种不同的颜色n次说Hello World,其中n是从不同存储库中的配置文件中读取的 并通过python程序生成页面 如果我们可以使用Javascript来显示颜色,那会更有帮助。我能够多次显示hello world,但我不知道如何更改颜色。 以下是我迄今为止编写的代码:

 import  ConfigParser
 import webbrowser

 configParser = ConfigParser.RawConfigParser()
 configParser.read("/home/suryaveer/check.conf")
 num = configParser.get('userinput-config', 'num')
 num2 = int(num)
 hello = """"hello world """
 hello2 = hello*num2
 message = """<html><head>
 </head><body><p>"""+hello2+"""</p></body>
 </html>"""
 f = open('x.html', 'w')
 f.write(message*num2)
 f.close()
 webbrowser.open("file:///home/suryaveer/x.html")
导入配置解析器
导入网络浏览器
configParser=configParser.RawConfigParser()
configParser.read(“/home/suryaveer/check.conf”)
num=configParser.get('userinput-config','num')
num2=int(num)
你好=“你好,世界”
hello2=你好*num2
message=”“”
“+hello2+”

""" f=打开('x.html','w') f、 写入(消息*num2) f、 关闭() 网络浏览器打开(“file:///home/suryaveer/x.html")
为了给每个“hello world”设置不同的样式,它们必须位于不同的HTML块中。您可以在
span
中包装“hello world”的每个实例

hello = """"<span>hello world </span>"""

如果您需要更多帮助或想了解其他选项(Javascript),请告诉我。

最后我解决了我的问题

```

导入配置解析器
导入网络浏览器
随机输入
def test():
r=lambda:random.randint(0255)
返回(“#%02X%02X%02X%”(r(),r(),r())
configParser=configParser.RawConfigParser()
configParser.read(“/home/suryaveer/check.conf”)
num=configParser.get('userinput-config','num')
num2=int(num)
message=“”

你好,世界

“”“ 打印“从文件读取的编号:+str(num2) f=open('out.html','w') 对于范围内的i(0,num2): 打印消息 f、 写入(message.format(test())) f、 关闭() 网络浏览器打开(“file:///home/suryaveer/out.html")

```

请在您尝试完成此任务的地方分享代码。它将帮助社区帮助您解决问题。我需要更多帮助:-)因为我想从配置文件中获取输入,就像我想要输出一样,我想分别以颜色数输入我想要打印hello world的次数,请帮助:-)如果你可以说明其他选项这将是一个很大的帮助PS:不介意英语看这里-
colors = [color1, color2, ... colorN]  # List of n colors

hello2 = ""
for c in colors:
    hello2 += """"<span style='color:{};'>hello world </span>""".format(c)
import  ConfigParser
import webbrowser
import random
def test():
    r = lambda: random.randint(0, 255)
    return('#%02X%02X%02X' % (r(),r(),r()))
configParser = ConfigParser.RawConfigParser()
configParser.read("/home/suryaveer/check.conf")
num = configParser.get('userinput-config', 'num')
num2 = int(num)
message = """<p style='color:{};'>hello world</p>"""
print "number read from file : " + str(num2)
f = open('out.html', 'w')
for i in range(0, num2):
    print message
    f.write(message.format(test()))
f.close()
webbrowser.open("file:///home/suryaveer/out.html")