Qiyuan 學習檔案位址

2021-09-29 07:23:05 字數 1450 閱讀 9351

import os

dd = os.getcwd(

)# 獲得當前的檔案位址

# 1.新建乙個資料夾\

final = dd+

'\英雄**'

print

(final)

try:

os.mkdir(final)

# 新建資料夾

except

:print

("已經有這個資料夾了"

)print

(os.getcwd())

# 改變change 資料夾directory

os.chdir(r'c:\users\jrcode01\pycharmprojects\untitled1\英雄**'

)print

(os.getcwd())

dd = os.getcwd(

)listname =

['達摩'

,'典韋'

,'曹操'

,'鍾無艷'

,'墨子'

,'趙雲'

]for i in listname:

print

(i)print

(dd +

'\\'

+ i)

try:

os.mkdir(dd +

'\\'

+ i)

except

:print

('這個資料夾已經有了'

)

import os

os.chdir(

'./英雄**/曹操'

)# change + directory

name = os.listdir(

)# 列出裡面de檔案名字

print

(name)

# **2.txt ===> new_**2.txt

count =

1for i in name:

count = count+

1 os.renames(i,

'new_'

+'**'

+str

(count)

+'.txt'

)

import os

import shutil

os.chdir(

'./英雄**/曹操'

)# shutil.move("new_**2.txt",'../趙雲/**1.txt')

name = os.listdir(

)# 列出裡面de檔案名字

count =

1for i in name:

count = count +

1 shutil.move(i,

'../典韋/**%d.txt'

%count)

qiyuan 學習html語言

lang en charset utf 8 文明祖安,家人共享title head 1.祖安大舞台,有媽你就來 2.順風四海皆兄弟,逆風盡是屠媽人 3.贏則雙親健在,輸則族譜 4.在祖安,只有強者才配擁有雙親 5.nmsl就是祖安人打招呼的方式,放媽過來吧 6.你的手速跟詞彙量足夠你在祖安保護自己的...

Linux學習 檔案

chmod 更改檔案9個屬性 linux檔案屬性有兩種設定方法,一種是數字,一種是符號。linux檔案的基本許可權就有九個,分別是owner group others三種身份各有自己的read write execute許可權。先複習一下剛剛上面提到的資料 檔案的許可權字元為 rwxrwxrwx 這...

Golang 學習 檔案

建立檔案 create 檔案不存在就建立,存在則將檔案內容清空。引數 name 檔案的路徑 絕對路徑 相對路徑 目錄分隔符 開啟檔案 open 以唯讀方式開啟檔案。檔案不存在,則開啟失敗。引數 name 檔案的路徑 絕對路徑 相對路徑 開啟檔案 openfile 以唯讀 只寫 讀寫方式開啟檔案。檔案...