搞不明白了 求大神讲解下
前面创建的2个函数没有问题正常运行 第3个函数报错Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\课件\最后1116668886611.py", line 18, in <module>
censored_text_creata('Try','lame!lame!lame!')
File "C:\Users\Administrator\Desktop\课件\最后1116668886611.py", line 17, in censored_text_creata
text_creata(name,clean_msg)
NameError: name 'text_creata' is not defined. Did you mean: 'text_create'?
代码如下:
def text_create(name,msg):
desktop_path = 'C:\\Users\\Administrator\\Desktop\\'
full_path = desktop_path + name + '.txt'
file = open(full_path,'w')
file.write(msg)
file.close()
text_create('hello','hello word')
def text_filter(word,censored_word = 'lame',changed_word = 'Awesome'):
return word.replace(censored_word,changed_word)
text_filter('Python is lame')
def censored_text_creata(name,msg):
clean_msg = text_filter(msg)
text_creata(name,clean_msg)
censored_text_creata('Try','lame!lame!lame!') 卧槽 找到原因了
方法名打错了吧, 最后一个 e 打错成了 a,即 text_creata 改成 text_create
是的 开始没有注意到
页:
[1]