我正在嘗試在 Ren'Py 作業,但我發現了一些非常奇怪的東西。在很早的階段,我定義了這個類:
init python:
class Person:
def __init__(self, character, name):
self.ch = character
self.name = name
但后來我意識到,我不需要那個類中的名稱引數,因為我在字符引數中提供它,所以我洗掉它,現在類看起來像這樣:
init python:
class Person:
def __init__(self, character):
self.ch = character
但是現在,當我實體化類時,這是奇怪的部分:
default test = Person(Character("Test"))
它一直給我一個錯誤:
TypeError: __init__() missing 1 required positional argument: 'name'
據我了解,它需要“名稱”引數,但我已經從課堂上洗掉了它,所以我不明白它怎么還想要它。當我嘗試這樣的事情時:
default test = Person(Character("Test"), "test")
它作業得很好,對我來說沒有任何意義,我對此感到非常困惑。有什么方法可以重置課程嗎?
uj5u.com熱心網友回復:
好的,我終于弄清楚問題出在哪里了。它在 VS Code 中,更準確地說是在“.vscode”檔案夾中,其中有“Settings.json”檔案,其中有幾行用于排除某些檔案以獲得更干凈的作業空間。出于某種原因,我在那里有一條額外的線路,這導致了問題。
.vscode/Settings.json:
{
"files.exclude": {
"**/*.rpyc": true,
"**/*.rpa": true,
"**/*.rpymc": true,
"**/cache/": true
}
}
有問題的行是:
"**/cache/": true
洗掉此行后,一切都解決了。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/507299.html
