day5-Python學習筆記(十)常用模組

來源:互聯網
上載者:User

標籤:name   exist   判斷   std   curd   擷取   cal   post   path   

import os
# print(os.getcwd())#取當前工作目錄
# print(os.chdir("..")) # 更改目前的目錄
# print(os.getcwd())#取當前工作目錄

# print(os.curdir) # 目前的目錄,相對路徑
# print(os.pardir) # 父目錄,相對路徑

# print(os.mkdir("test1")) # 建立檔案夾
# print(os.rmdir("test1")) # 只能刪除空檔案夾
# print(os.remove("../day4/5.png")) # 刪除檔案,不能刪檔案夾。
# print(os.listdir(‘c://‘)) # 列出一個目錄下的所有檔案
# os.rename("test", "test1") # 重新命名
# print(os.stat("筆記.txt"))#擷取檔案資訊
# print(__file__) #__file__就是這個檔案的絕對路徑
# print(os.path.abspath(__file__)) # 擷取絕對路徑
# print(os.path.split("c:\\usr\\hehe\\hehe.txt")) # 分割路徑和檔案名稱
# print(os.path.dirname("c:\\usr\\hehe\\hehe.txt")) # 擷取父目錄
# print(os.path.basename("c:\\usr\\hehe\\hehe.txt")) # 擷取最後一級,如果是檔案顯示檔案名稱,如果是目錄顯示目錄名
# print(os.path.exists("c://test2")) # 目錄/檔案是否存在
# print(os.path.isfile(r"E:\txz\day2.zip"))#判斷是否是一個檔案
# print(os.path.isdir(r"E:\txz\day2"))#是否是一個檔案夾
# name = ‘a.sql‘
# print(os.path.join("e",name))#拼接成一個路徑

# print(os.sep) # 當前作業系統的路徑分隔字元
# print(os.linesep) # 當前作業系統的分行符號
# print(os.pathsep) # 當前系統的環境變數中每個路徑的分隔字元,linux是:,windows是;
# print(os.environ) # 當前系統的環境變數
# print(os.name) # 當前系統名稱
# c://java/jre;c://python
# /usr/local:/root
#os.system(‘dir‘) #用來執行作業系統命令,只能執行,擷取不到結果
# res = os.popen(‘ipconfig‘) #用來執行作業系統命令,並且擷取到返回結果.read
# print(res.read())

#常量
import sys
# print(sys.path) #環境變數
# print(sys.platform) #看當前系統是什麼
# print(sys.version)#看python的版本
# print(sys.exit(‘程式退出‘))
# quit(‘程式退出‘) #退出程式
# print(‘hahaha‘)
# def fun(a):
# pass
print(sys.argv) #是擷取運行python檔案的時候 傳入的參數

#python xxx.py

day5-Python學習筆記(十)常用模組

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.