<a href="http://www.lxweimin.com/p/54870e9541fc">總目錄</a>
課程頁面:https://www.udacity.com/course/programming-foundations-with-python--ud036
授課教師:Kunal Chawla
如下內容包含課程筆記和自己的擴展折騰
打開網站
參見:https://pymotw.com/2/webbrowser/
# -*- coding: utf-8 -*-
import webbrowser
webbrowser.open('https://classroom.udacity.com/mex')
等待一段時間再運行
參見:http://stackoverflow.com/questions/15472707/make-python-program-wait
# -*- coding: utf-8 -*-
import webbrowser
import time
time.sleep(5) #5 seconds
webbrowser.open('https://classroom.udacity.com/mex')
當前時間
# -*- coding: utf-8 -*-
import webbrowser
import time
print "Current time", time.ctime()
for i in range(2):
time.sleep(5) #5 seconds
webbrowser.open('https://classroom.udacity.com/me')
The Python Standard Library
https://docs.python.org/2.7/library/index.html
修改文件名
# -*- coding: utf-8 -*-
import os
def rename_files():
#(1) get file name from a folder
file_list = os.listdir("/Users/yawenzhang/Downloads/prank")
saved_path = os.getcwd()
os.chdir("/Users/yawenzhang/Downloads/prank")
#(2) for each file, rename filename
for filename in file_list:
os.rename(filename, filename.translate(None,'0123456789'))
os.chdir(saved_path)
rename_files()
【內容待補全】