python读入文件和time/sys模块的简单使用

python读入文件和time/sys模块的简单使用 

一些标准库函数的用法也待学习,如:os/re/sets/string/queue/socket 

Python代码  

#!/usr/bin/python    print ord('a')  print chr(97)  #字符和整型互相转换    fp = open("file.tmp")  for line in fp.readlines():    print line,  #文件操作readlines()函数一次读入多行,循环输出  for line in fp:    print line,

登录后复制

立即学习“Python免费学习笔记(深入)”;

Python代码  

#!/usr/bin/python  import time  #time模块使用    print time.localtime().tm_year  #time.struct_time(tm_year/tm_mon/tm_mday/tm_hour/tm_min/tm_sec/  #tm_wday/tm_yday/tm_isdst)  print time.asctime()  #time() localtime() gmtime() ctime() strftime() strptime()   #clock() sleep()

登录后复制

立即学习“Python免费学习笔记(深入)”;

Python代码  

#!/usr/bin/python  import sys    print sys.platform  print sys.argv[0]  print sys.argv[1]

登录后复制

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。

发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2281603.html

(0)
上一篇 2025年2月27日 18:47:16
下一篇 2025年2月27日 18:47:28

AD推荐 黄金广告位招租... 更多推荐

发表回复

登录后才能评论