社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Python

在python中,不能删除句点''。

Rick Crespo • 7 年前 • 2182 次点击  

试图找出如何从我的输出中删除句点。作业的正确答案是:wa。EA。人工智能.六、六 我的输出是:wa。EA。人工智能。阿维。

我试过用rstrip删除。但那不起作用。

感谢您对这个新手python程序员的一些见解。

stopwords = ['to', 'a', 'for', 'by', 'an', 'am', 'the', 
'so', 'it', 'and', 'The']
sent = "The water earth and air are vital"
s_sent=sent.split()
acro = ''
for word in s_sent:
    if word not in stopwords:
       acro=acro + str.upper(word[:2])+". "            
       acro=acro.rstrip('.')
print(acro)
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/43011
文章 [ 3 ]  |  最新文章 7 年前