'''def display_name(name, age, tel):
print(f"你好我是{name},今年{age}岁,电话{tel}。")
name = "hl"
age = 20
tel = "123"
display_name(name, age, tel)
def get_score(*score, name):
print(f"{name}")
print(max(score))
print(min(score))
print(sum(score)/len(score))
get_score(12, 21, 3, 4, 14, 6, name = 'hl')'''
'''def changearg(**j):
print(j)
changearg(a=1,b=3)
def mix(*args, **kwargs):
for arg in args:
print(arg)
for key, value in kwargs.items():
print(f"{key}-->{value}")
mix("a", 2, name="ghl", item = "33")
def mix(*args, **kwargs):
for arg in args:
print(arg)
for key, value in kwargs.items():
print(f"{key}-->{value}")
mix("a", 2, name="ghl", item = "33")
a=100
def local(a):
a=200
print(a)
print(a)
print(local(a))
from print import random as r
print(r.randint(1,5))
import math
m=math
sigmoid_a = lambda a,b: a+1/1+m.exp(-b)
print(sigmoid_a(5,6))
'''
'''class A:
def __call__(self):
print("__call__")
def __copy__(self):
print("__copy__")
a=A()
a()
class B:
def __str__(self):
return "hello"
b=B()
print(b)
class L:
def __len__(self):
return 100
l=L()
print(len(l))
class Student:
def __init__(self, name, age, sex, num):
print(f"name: {name}, age: {age}, sex: {sex}, num: {num}")
stu1 = Student(name="ghl", age=20, sex="men", num="123456")
'''
'''class a:
def __new__(cls):
print('__new__')
return object.__new__(cls)
def __init__(self):
print('__init__')
def __del__(self):
print("__del__")
def dis_name(self):
print("name")
a1 = a()
a1.dis_name()
class Utils:
def factorial(n):
if n == 0 or n == 1:
return 1
else:
return n * Utils.factorial(n - 1)
result = Utils.factorial(10)
print(result)
'''
'''
import os
fl = os.listdir(r"d:\\")
print(fl)
for fn in fl:
#判断是文件夹还是文件
if os.path.isdir(f"d:\\{fn}"):
print(f"路径d:\\{fn}")
elif os.path.isfile(f"d:\\{fn}"):
print(f"文件d:\\{fn}")'''
import os
count_txt=0
count_py=0
count_dll=0
count_exe=0
def get_dir(path):
file_lists = os.listdir(path)
for file in file_lists:
file_path=f"{path}//{file}"
if os.path.isdir(file_path):
get_dir(file_path)
else :
if file_path.endswith(".txt"):
#如果是".txt"后缀名文件
print(f"txt文件:{file_path}")
global count_txt
count_txt= count_txt + 1
elif file_path.endswith(".py"):
#如果是".py"后缀名文件
print(f"py文件:{file_path}")
global count_py
count_py = count_py + 1
elif file_path.endswith(".dll"):
#如果是".dll"后缀名文件
print(f"dll文件:{file_path}")
global count_dll
count_dll = count_dll + 1
elif file_path.endswith(".exe"):
#如果是".exe"后缀名文件
print(f"exe文件:{file_path}")
global count_exe
count_exe = count_exe + 1
else:
return
get_dir(r"E:\Wechat开发")
print(f"有{count_txt}个txt文件,有{count_py}个py文件,有{count_dll}个dll文件,有{count_exe}个exe文件")
import os
count_txt = 0
count_py = 0
count_dll = 0
count_exe = 0
def count_files(path):
global count_txt, count_py, count_dll, count_exe
file_lists = os.listdir(path)
for file in file_lists:
file_path=os.path.join(path,file)
if os.path.isdir(file_path):
count_files(file_path)
else:
if file_path.endswith(".txt"):
count_txt += 1
elif file_path.endswith(".py"):
count_py += 1
elif file_path.endswith(".dll"):
count_dll += 1
elif file_path.endswith(".exe"):
count_exe += 1
target_dir = r"E:\Wechat开发"
count_files(target_dir)
print(f"有 {count_txt} 个txt文件,有 {count_py} 个py文件,有 {count_dll} 个dll文件,有 {count_exe} 个exe文件")