【发布时间】:2019-03-29 23:15:52
【问题描述】:
我正在为一群朋友设置一个个人项目,但出现此错误:
Traceback(最近一次调用最后一次): 文件“C:\Users[my pc name]\Downloads\Python code\meme documentation.py”,第 11 行,在 line = line.re(char,'') AttributeError: 'tuple' 对象没有属性 're'
我浏览了互联网,找不到与我遇到的问题相关的任何内容。这是我的代码:
import re
name = input("What is the name of this meme?")
age = input("How Old is this meme?")
purpose = str(input("please state the purpose of this meme: (if there is none, reply with 'N/A'"))
wholeAssDocumentation = ("This meme is known as the" , name , "and it is" , age , "years old. Its purpose was:" , purpose)
print = (wholeAssDocumentation)
line = (wholeAssDocumentation)
for char in "( ?.!/;:)'":
line = line.re(char,'')
预期:它会完全删除字符串中列出的字符(因为它出现在我要写入的文本文件中)
Actual: Traceback (most recent call last):
File "C:\Users\[my pc name]\Downloads\Python code\meme documentation.py", line 11, in <module>
line = line.re(char,'')
AttributeError: 'tuple' object has no attribute 're'
【问题讨论】:
-
line = line.re(char,'')你想在这里做什么? -
我正在尝试用“”(空格)替换列出的字符
-
print = (wholeAssDocumentation)??从这里开始:docs.python.org/3/tutorial -
我打算删除它,因为它只是为了测试目的,然后就没有删除它。
-
这也不是如何使用打印功能....
标签: python python-3.x