有没有办法在不运行 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 themfiles = {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: "))
添加回答
举报
0/150
提交
取消