python编程问题! 有一个txt文件,每一行有两个数据,之间用制表符隔开,怎么实现只读每一行的

python编程问题! 有一个txt文件,每一行有两个数据,之间用制表符隔开,怎么实现只读每一行的,第1张

#!/usr/bin/env python# coding: utf-8## filename: baidu_wordpyimport repatt = recompile(r"^[a-z]{6,}$")def wordinput(): """input a word word length at least 6, no space, no digit and no symbol """ while 1: word = raw_input("Input a word: ") if pattmatch(word): return worddef specialshow(word): """prints the first three characters, followed by three periods(), and then the last three characters """ print "%s%s" % (word[:3], word[-3:])def main(): specialshow(wordinput())if __name__ == "__main__": main()


欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/yw/13408123.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-07-30
下一篇 2023-07-30

发表评论

登录后才能评论

评论列表(0条)

保存