您好,欢迎来到喜迪情感。
搜索
您的当前位置:首页python读入文件和time/sys模块的简单使用

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代码

#!/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代码

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

Copyright © 2019- xdyj.cn 版权所有

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务