Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7accce6

Browse files
committed
Remove unused files and add Chapter 11.4 challenge solution
1 parent7110008 commit7accce6

File tree

19 files changed

+27
-120
lines changed

19 files changed

+27
-120
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# 11.4 Challenge: Move All Image Files To a New Directory
2+
# Solution to Challenge
3+
4+
frompathlibimportPath
5+
6+
# Change this path to match the location on your computer
7+
documents_dir= (
8+
Path.home()/
9+
"python-basics-exercises"/
10+
"ch11-file-input-and-output"/
11+
"practice_files"/
12+
"documents"
13+
)
14+
15+
# Create an images/ directory in your home directory
16+
images_dir=Path.home()/"images"
17+
images_dir.mkdir(exist_ok=True)
18+
19+
# Search for image files in the documents directory and move
20+
# them to the images/ directory
21+
forpathindocuments_dir.rglob("*.*"):
22+
ifpath.suffix.lower()in [".png",".jpg",".gif"]:
23+
path.replace(images_dir/path.name)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Yo dad, what's up?
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1,2,3,4,5
2+
a,b,c,d,e
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
42

‎ch11-file-input-and-output/practice_files/example.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎ch11-file-input-and-output/practice_files/pastimes.csv

Lines changed: 0 additions & 5 deletions
This file was deleted.

‎ch11-file-input-and-output/practice_files/poem.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎ch11-file-input-and-output/practice_files/tabbed wonka.csv

Lines changed: 0 additions & 4 deletions
This file was deleted.

‎ch11-file-input-and-output/practice_files/wonka.csv

Lines changed: 0 additions & 4 deletions
This file was deleted.

‎ch11-file-input-and-output/sample_csv.csv

Lines changed: 0 additions & 101 deletions
This file was deleted.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp