有没有办法在不运行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: "))