Python reads files and simple use of time/sys module

巴扎黑
Release: 2016-12-09 14:30:57
Original
1883 people have browsed it

Simple use of python to read files and time/sys module

The usage of some standard library functions also needs to be learned, such as: os/re/sets/string/queue/socket

Python code

#!/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,
Copy after login



Python code

#!/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()
Copy after login



Python code

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


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template