Python_26_Udacity_Chawla_Python Foundation

<a href="http://www.itdecent.cn/p/54870e9541fc">總目錄</a>


課程頁面:https://www.udacity.com/course/programming-foundations-with-python--ud036
授課教師:Kunal Chawla
如下內(nèi)容包含課程筆記和自己的擴展折騰

打開網(wǎng)站

參見: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()

【內(nèi)容待補全】

最后編輯于
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容