|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
前面创建的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
|
|