Home >Backend Development >Python Tutorial >Python reads files and simple use of time/sys module
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,
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()
Python code
#!/usr/bin/python import sys print sys.platform print sys.argv[0] print sys.argv[1]