扣丁学堂Python培训解析如何去掉string中的标点符号方法

2019-01-23 13:29:58 364浏览

今天扣丁学堂Python培训老师给大家分享一篇关于python3去掉string中的标点符号方法详解,首先python去掉字符串中的标点符号的方法,大多是基于python2的,不适用python3,调整后代码如下:



代码

lower_case_documents = ['Hello, how are you!','Win money, win from home.','Call me now.','Hello, Call hello you tomorrow?']
sans_punctuation_documents = []
import string
 
for i in lower_case_documents:
  # TODO
  trantab = str.maketrans({key: None for key in string.punctuation})
  j = i.translate(trantab)
  sans_punctuation_documents.append(j)
 
print(sans_punctuation_documents)
 
['hello how are you', 'win money win from home', 'call me now', 'hello call hello you tomorrow']

以上就是关于扣丁学堂Python培训解析如何去掉string中的标点符号方法的全部内容了,希望对大家的学习有所帮助,扣丁学堂IT职业在线学习教育平台为您提供权威的Python视频教程课程,还有扣丁学堂老师精心推出的Python视频直播课定能让你快速掌握Python从入门到精通开发实战技能。扣丁学堂Python技术交流群:279521237。

扣丁学堂微信公众号 


关注微信公众号获取更多学习资料 

 

查看更多关于"Python开发资讯"的相关文章>

标签: Python培训 Python视频教程 Python在线视频 Python学习视频 Python培训班

热门专区

暂无热门资讯

课程推荐

微信
微博
15311698296

全国免费咨询热线

邮箱:codingke@1000phone.com

官方群:148715490

北京千锋互联科技有限公司版权所有   北京市海淀区宝盛北里西区28号中关村智诚科创大厦4层
京ICP备12003911号-6   Copyright © 2013 - 2019

京公网安备 11010802030908号