Python 3.8.2 Shell中表示日语字符的问题

2024-05-23 19:44:50 发布

您现在位置:Python中文网/ 问答频道 /正文

### Reorganizes copy and pasted list input and divides between what was found in dict and not found
import csv
raw_list = []
path = r'D:\Monolingual Frequency List.csv'
#open file, append each line to raw_list
with open(path, 'r',encoding='utf-8') as csv_file:
    csv_reader = csv.reader(csv_file)
    for line in csv_reader:
        raw_list.append(line)
    csv_file.close()
#create new list with padded values so as to properly sort
padded_list = []
for word, value in raw_list:
    #len of the most common = amount of padding required
    padded_list.append((word,value.zfill((len(raw_list[0][1])))))
def thinner_sorter(list):
    #takes out reoccurrences of words, sorts the words
    jl = [] #will be list of inputted words with their values
    jl_only_word =[] #gets only the words
    not_in =[] #words / phrases not recognized by dictionary
    unique_j = [] #used to get rid of reoccurrences of words
    for word in list:
        if word not in unique_j:
            unique_j.append(word)
    for list_word in unique_j:
        for word_file, num_file in padded_list:
            if list_word == word_file:
                jl.append((list_word,num_file))
    print('\n')
    jl.sort(key = lambda x:x[1], reverse = True) # takes in x, returns x[1]
    for x, y in jl:
        print(x)
    for word, value in jl:
        jl_only_word.append(word)
    for line in unique_j:
        if line not in jl_only_word:
            not_in.append(line)
    if len(not_in) > 0:
        print('*****NOT FOUND*****')
        for word in not_in:
            print(word)
    else:
        print('All words found.')
print('Paste your list of words: ')
j_list_lines = []
list_input = True
while list_input:
    line = input()
    if line:
        j_list_lines.append(line)
    else:
        break
thinner_sorter(j_list_lines)

这是代码,如果这很重要的话。当我从中创建py.exe文件时,它似乎无法识别日文字符,因此给出了这个图像screenshot

我不知道如何解决这个问题。就像我说的,它在Pycharm中运行良好我也确信代码很烂,但这不是我现在的问题


Tags: ofcsvinforrawlinenotlist