hello python!

First day

Python is not that difficult, the only thing you need to know is you are not just a learner. I’m going to do a project with it.

Here is what I learned on the first day.

How to make a breaker:

1
2
3
4
5
6
7
8
9
import time
import webbrowser
total_break =3
break_count =0
print("My program started at "+ time.ctime())
while(break_count < total_break):
time.sleep(1*60*60)
webbrowser.open("https://www.youtube.com/watch?v=Cazye_CUTL4")
break_count = break_count + 1

This python code helps me do my job more efficiently. Hope I can continue my learning and make a difference this time.

How to rename file names

Here is the code:

1
2
3
4
5
6
7
8
9
import os # import the module you are going to use.
def rename_files():
file_list = os.listdir("/Users/mingyugu/Downloads/prank")
os.chdir("/Users/mingyugu/Downloads/prank")
file_list = os.listdir("/Users/mingyugu/Downloads/prank")
saved_path = os.getcwd()
for file_name in file_list:
os.rename(file_name,file_name.translate(None,"1234567890"))
os.chdir(saved_path)

This one allows you to change your directory , list the file in this directory, and get the current working path.