Python_26_Udacity_Chawla_Python Foundation

<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()

【內容待補全】

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容