admin管理员组文章数量:1619183
有没有办法在不运行web服务器的情况下,在web浏览器上本地运行(.py)Python文件?也不使用外部服务。因此,如果internet不可用,该文件仍将在浏览器中运行。我想在我的电脑上用Chrome或IE运行这个代码。谢谢。在def concept(phrase):
# split var(phrase) at spaces and assign to var(words)
words = phrase.split()
# use this to list python file titles and links to open them
files = {1:"file0001.txt",
2:"file0002.txt",
3:"file0003.txt",
4:"file0004.txt",
5:"file0005.txt",
6:"file0006.txt",
7:"file0007.txt",
8:"file0008.txt",
9:"file0009.txt"}
# change keys to searchable simple keyword phrases.
concepts = {'GAMES':[1,2,4,3,3],
'BLACKJACK':[5,3,5,3,5],
'MACHINE':[4,9,9,9,4],
'DATABASE':[5,3,3,3,5],
'LEARNING':[4,9,4,9,4]}
# iterate through all var(words) found in var(word)
for word in words:
# convert to uppercase, search var(word) in dict 'concepts', if not found return not found"
if word.upper() not in concepts:
print("'{}':Not Found in Database \n" .format(word)) not in concepts
else:
# for matching keys in dict 'concept' list values in dict 'files'
for pattern in concepts[word.upper()]:
print(files[pattern])
# return input box at end of query
while True:
concept(input("Enter Concept Idea: "))
版权声明:本文标题:python文件运行在浏览器中打开_如何在web浏览器中本地运行(.py)Python文件? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dongtai/1728788395a1173509.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论