Python read-in files and simple use of time/sys modules

Source: Internet
Author: User
Python read-in files and simple use of time/sys modules

The use of some standard library functions is also to be learned, such as: Os/re/sets/string/queue/socket

Python code

#!/usr/bin/python    Print ord (' a ')  print CHR  #字符和整型互相转换    fp = open ("file.tmp")  for line in Fp.readlines ():    print line,  #文件操作readlines () function reads multiple lines at once, loops the output for the in  fp:    print,



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]
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.