我如何放置这个 python 脚本:
a = ['f','d','s','a']
x = -1
scope = vars()
for i in a:
scope['x']+=1
print a[x]
在 html 文件中?
最佳答案
像这样,如果你想创建一个html,不一定要显示它:
html_file = open('namehere.html','w')
a = ['f','d','s','a']
x = -1
scope = vars()
data = ''
for i in a: #TIP: use a generator
scope['x']+=1
data += a[x]
data += '\n'
html_file.write(data)
html_file.close()
关于python - 如何在 HTML 文件中包含 python 脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4161332/