2017-01-13 16 views
0

これはなぜ動作しないのですか?あなたはこのような関数ヘッダで変数を置くときsolution1_s()が見つかりません1必要な位置引数: 'sol_s1'

Traceback (most recent call last):
    File "C:\Program Files\Python34\lib\tkinter__init__.py", line 1533,
    in call return self.func(*args)
   TypeError: solution1_s() missing 1 required positional argument: 'sol_s1'

solutions_s={ 
    "sol_s1":"if this is happeing to you, there is a bug in the software. call up your supplier and they will try and troubleshoot the phone. make sure you have all the latest updates installed", 
    "sol_s2":"these are all signs of a virus. the deleting of applications is virus munching on your data, and pop ups on your scren is also a virus symptom. immiditely use your antivirus to look for the problem or take it to a repair shop where they can delete the virus", 
    "sol_app":"check if you have enogh storage on your device, if you dont and that was the problem, then see if you can get a storage upgrade. However, if it isnt there is a good chance you have a virus on your phone. scan your phone with an antivirus, or let your local repair shop do it", 
    "sol_pop":"if the pop ups are on a web browser, this is normal. try getting an ad blocker if it is bothering you, but do not click on them. however, if it is happening on the main screen, you have contracted a virus. use your antivirus orget it fixed at a repair shop", 
    "sol_s3":"this is another sign of a software fault. the only one who can fix this is your supplier. contact them as soon as possible"} 

def solution1_s(sol_s1): 
    label20=Label(screen,text=solutions_s[sol_s1]) 
    label20.pack() 
    sys.exit() 
def solution2_s(sol_s2): 
    label22=Label(screen,text=solutions_s[sol_s2]) 
    label22.pack() 
    sys.exit() 
def solution_app(sol_app): 
    label23=Label(screen,text=solutions_s[sol_app]) 
    label23.pack() 
    sys.exit() 
def solution_pop(sol_pop): 
    label24=Label(screen,text=solutions_s[sol_pop]) 
    label24.pack() 
    sys.exit() 
def solution3_s(sol_s3): 
    label26=Label(screen,text=solutions_s[sol_s3]) 
    label26.pack() 
    sys.exit() 
+0

、明白なことを述べるために:あなたは引数を指定せずに関数をtkinterで呼び出しています。 – nlsdfnbch

答えて

1

def solution1_s(sol_s1): 

Pythonは、あなたがそれを渡すことを期待する代わりにソリューションを印刷する

は、それがこのエラーを生成します引数には何でもかまいません。その関数のスコープ内にsol_s1という名前を付けます。

ただし、スクリプト内で宣言したsolutions_sの辞書にあるsol_s1のキーを検索すると思われます。

代わりにこれを試してみてください:

def solution1_s(): 
    label20=Label(screen,text=solutions_s['sol_s1']) 
    label20.pack() 
    sys.exit() 

ここスコープとdictsに関する詳細な議論といくつかの読み物だ:

まあ

Scopes

Dictionaries

+0

いいえ、まだdousnt仕事@ nlsdfnbch – Fuzee

+1

ach shucks、あなたはもちろん、引用符でキーを置く必要があります。 – nlsdfnbch

+0

すみません、私はPythonに新しいです。あなたは@nlsdfnbchを説明してください。 – Fuzee

関連する問題