mirror of https://gitee.com/hikerxiang/ciyun
parent
a46f6a0a76
commit
e0d08e7c08
@ -1,91 +0,0 @@
|
||||
# -*- coding=utf-8 -*-
|
||||
import os
|
||||
|
||||
|
||||
# 检验是否全是中文字符
|
||||
def is_all_chinese(strs):
|
||||
for _char in strs:
|
||||
if not '\u4e00' <= _char <= '\u9fa5':
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
# 检验是否包含中文字符
|
||||
def is_chinese(strs):
|
||||
for ch in strs:
|
||||
if u'\u4e00' <= ch <= u'\u9fff':
|
||||
return True
|
||||
return False
|
||||
|
||||
#
|
||||
def result():
|
||||
path = "D:/Hiker/Ku/Python_ku/Python_ku_one/file" # 文件夹目录,运行前记得修改!!!!!!!!!!!!
|
||||
files = os.listdir(path) # 得到文件夹下的所有文件名称
|
||||
print(files[0])
|
||||
|
||||
txts = []
|
||||
i = 1
|
||||
|
||||
for file in files: # 遍历文件夹
|
||||
position = path + '\\' + file # 构造绝对路径,"\\",其中一个'\'为转义符
|
||||
print(i, '--- ', end='')
|
||||
print(file, end='')
|
||||
i = i + 1
|
||||
with open(position, "r", encoding='utf-8') as f: # 打开文件
|
||||
data = f.read() # 读取文件
|
||||
if (is_all_chinese(data)):
|
||||
print(" (纯中文)")
|
||||
|
||||
|
||||
|
||||
else:
|
||||
if (is_chinese(data)):
|
||||
print(" (有英文有中文)")
|
||||
|
||||
else:
|
||||
print(" (纯英文)")
|
||||
|
||||
def getf(b):
|
||||
path = "D:/Hiker/Ku/Python_ku/Python_ku_one/file" # 文件夹目录,运行前记得修改!!!!!!!!!!!!
|
||||
files = os.listdir(path) # 得到文件夹下的所有文件名称
|
||||
|
||||
return files[b]
|
||||
|
||||
|
||||
def chuli(b):
|
||||
path = "D:/Hiker/Ku/Python_ku/Python_ku_one/file" # 文件夹目录,运行前记得修改!!!!!!!!!!!!
|
||||
files = os.listdir(path) # 得到文件夹下的所有文件名称
|
||||
|
||||
|
||||
txts = []
|
||||
i = 1
|
||||
|
||||
position = path + '\\' + files[b] # 构造绝对路径,"\\",其中一个'\'为转义符
|
||||
|
||||
|
||||
|
||||
with open(position, "r", encoding='utf-8') as f: # 打开文件
|
||||
data = f.read() # 读取文件
|
||||
if (is_all_chinese(data)):
|
||||
a='z'
|
||||
return a
|
||||
|
||||
|
||||
|
||||
|
||||
else:
|
||||
if (is_chinese(data)):
|
||||
|
||||
a='zy'
|
||||
return a
|
||||
|
||||
else:
|
||||
|
||||
a='y'
|
||||
return a
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in new issue