我一直在使用概念来跟踪我的习惯和财务状况。现在我想使用 Notion API 从数据库中获取数据。但是概念 API 需要数据库 ID,但我似乎找不到它。
虽然这里的用例并不那么重要,但实际上的用途很重要。我想像我们一样通过浏览器浏览用户本地文件系统,<input type="file">但我不想选择一个文件,而是选择一个目录并获取其中所有文件和目录的列表。
一旦获得文件列表,我想以树状视图结构递归地显示它们。
这是我知道可以通过File System Access Api完成的示例。
我只想使用这个 API 来创建文件管理器或树视图之类的东西。
谢谢。
import random
from IPython.display import clear_output
dictionary = open("words_50000.txt","r")
dict_5000 = dictionary.readlines()
guess = random.choice(dict_5000).lower().strip('\n')
no_of_letters = len(guess)
game_str = ['-']*no_of_letters
only_length=[]
def word_guesser():
only_length_words()
print(dict_5000)
def only_length_words():
for i in range(len(dict_5000)):
if len(dict_5000[i].strip('\n'))!=no_of_letters:
dict_5000.pop(i)
word_guesser()
Run Code Online (Sandbox Code Playgroud)
-------------------------------------------------- ------------------------- IndexError Traceback (最近一次调用) in () 20 dict_5000.pop(i) 21 ---> 22 word_guesser ()
在 word_guesser() 11 12 def word_guesser(): ---> 13 only_length_words() 14 print(dict_5000) 15
在 only_length_words() 17 def only_length_words(): 18 for i in range(len(dict_5000)): ---> 19 if len(dict_5000[i].strip('\n'))!=no_of_letters: 20 dict_5000。流行音乐(一) 21
IndexError:列表索引超出范围