誰かが私に持っている問題を手伝ってもらえますか?私は、ユーザーが日記と呼ばれる特定のファイルを選択して現在のスキルレベルと比較できるようにするいくつかのコードを試そうとしています。各ファイルには、別々の辞書に入れたい簡単な、私が操作しようとしていたファイルを簡単にこの形式でtxtファイル内の構造化され、それが全体のファイルから正しい情報を印刷してもらうが、私は4つの別々の辞書python 3.xは1つのテキストファイルを4つの辞書に分割する助けが必要
# shows all osrs diarys
def diary_selection():
diary_options = {
0 : 'ardougne', 1 : 'desert', 2 : 'falador', 3 : 'fremennik', 4 : 'kandarin',
5 : 'lumbridge', 6 : 'morytania', 7 : 'varrock', 8 : 'western', 9 : 'wilderness'
}
print(diary_options)
# if not a correct number gives prompt to retry
while True:
try:
d_sel = int(input ("\nType in the number next to the diary: "))
diary_select = d_sel
if not (0 <diary_select> 9):
print('option is valid')
break
else:
print(" invalid option.")
diary_selection()
except ValueError:
print(" invalid option, numbers only, please try again.")
# gets the name of the diary acording to what number was pressed
current_diary = diary_options.get(diary_select)
#creats a filename for spicific diary
diary_file_name = str((current_diary + "_diary.txt"))
print (diary_file_name,"\n")
#searches for file name in folder ./diary_requirements
f = open("./diary_requirements/"+diary_file_name,"r")
file_contents = f.read()
return file_contents
にそれを分割する方法を見つけ出すカント、中位、ハード、エリートレベル。私はあなたが苦労一部だけを推測してい
easy_levels = {
"Attack" : 0
, "Defense" : 0
, "Strength" : 0
, "Hitpoints": 0
, "Range" : 30
, "Prayer" : 0
, "Magic" : 0
, "Cooking" : 0
, "Woodcutting" : 0
, "Fletching" : 20
, "Fishing" : 0
, "Firemaking" : 0
, "Crafting" : 0
, "Smithing" : 0
, "Mining" : 15
, "Herblore" : 0
, "Agility" : 0
, "Thieving" : 0
, "Slayer" : 0
, "Farming" : 0
, "Runecrafting" : 0
, "Hunting": 9
, "Construction" : 0
,
}
medium_levels = {
"Attack" : 0
, "Defense" : 0
, "Strength" : 0
, "Hitpoints": 0
, "Range" : 30
, "Prayer" : 0
, "Magic" : 0
, "Cooking" : 42
, "Woodcutting" : 35
, "Fletching" : 5
, "Fishing" : 46
, "Firemaking" : 35
, "Crafting" : 0
, "Smithing" : 0
, "Mining" : 40
, "Herblore" : 0
, "Agility" : 37
, "Thieving" : 0
, "Slayer" : 0
, "Farming" : 0
, "Runecrafting" : 0
, "Hunting": 31
, "Construction" : 0
,
}