为什么Python返回';无'; “” 功能“文本条分割(文本)”删除特殊符号和 开始和结束字符串中的空白,在我们输入字数之后, 它应该写,最后写这个字。 ''' def text_strip_split(文本): 列表=['!'、'、'、'、'、'?'、':'、'/'、'*'、'\'、'%'、'\'、'\'、'\'、'\'、'='、'+'、'&'、';'] 对于列表中的i: text=text.replace(i,,).strip() text=text.split() 打印() 尽管如此: x=int(输入('输入我应该在控制台上打印的数字字:\n'))-1 如果x>len(列表)或x
函数中没有返回语句。因为函数中没有返回语句。请告诉我如何简化或合并我的“列表”?@chepner我很感激你在关闭时删除了你的答案,没有返回值的部分。为什么Python返回';无'; “” 功能“文本条分割(文本)”删除特殊符号和 开始和结束字符串中的空白,在我们输入字数之后, 它应该写,最后写这个字。 ''' def text_strip_split(文本): 列表=['!'、'、'、'、'、'?'、':'、'/'、'*'、'\'、'%'、'\'、'\'、'\'、'\'、'='、'+'、'&'、';'] 对于列表中的i: text=text.replace(i,,).strip() text=text.split() 打印() 尽管如此: x=int(输入('输入我应该在控制台上打印的数字字:\n'))-1 如果x>len(列表)或x,python,list,Python,List,函数中没有返回语句。因为函数中没有返回语句。请告诉我如何简化或合并我的“列表”?@chepner我很感激你在关闭时删除了你的答案,没有返回值的部分。文本条带分割函数不返回值。我们能帮我吗?如何使用特殊符号组合或简化我的列表?可能是Python自带了什么函数或模块?@AlekseiGrabor您可能想看看string.标点符号。它包含所有ASCII标点符号。 ''' function 'text_strip_split(text)' delete special symbolsand w
文本条带分割
函数不返回值。我们能帮我吗?如何使用特殊符号组合或简化我的列表?可能是Python自带了什么函数或模块?@AlekseiGrabor您可能想看看string.标点符号。它包含所有ASCII标点符号。
'''
function 'text_strip_split(text)' delete special symbolsand
whitespace in start and end string,after we enter number of word ,
that it should write , and finally write this word.
'''
def text_strip_split(text):
list = [ '!' , ',' , '.' , '?' , ':' , '/' , '*' , '#' , '%' , '\\' , '_' , '-' , '=' , '+' , '&' ,';']
for i in list:
text = text.replace( i , ' ').strip()
text = text.split()
print()
while True:
x = int(input('Enter number word that i should print on console:\n')) - 1
if x > len(list) or x < 0:
print('Enter other number!')
else:
break
print(text[x])
word = input('Write the something text with special symbols: \n')
print(text_strip_split(word))