![](/img/trans.png)
[英]Can not figure out why my if/else statement doesn`t work like i intend
[英]Can't figure out why I can't import this one class, I feel like it should work
我在一個文件中創建了一個簡單的類,該文件與我嘗試發送的目錄位於同一目錄中。 但是,由於某些未知原因,我終生無法弄清楚為什么導入不起作用。 任何幫助都會很棒。
我已經用谷歌搜索了很多,但找不到任何特定於我的東西
有問題的類(名為 location1.py 的文件)
class Location:
def __init__(self, name, txt_display, been_there):
self.name = name
self.txt_display = txt_display
self.been_there = been_there
我所有的導入(名為 mainPart1.py 的文件)
import random
from tkinter import *
from location1 import *
from PIL import ImageTk, Image
我是如何測試的
temp = Loction("1a", "display poo", True)
print(temp.name)
“NameError: name 'Loction' is not defined” 我從終端得到這個,我不知道該怎么做。 我期待“1a”
你有一個錯字,它應該是Location
您的代碼:
temp = Loction("1a", "display poo", True)
應該:
temp = Location("1a", "display poo", True
)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.