相关疑难解决方法(0)

如何将希腊语字符转换为英语python

我想要一些 Python 代码,它接受希腊语句子并将其转换为英语字符。任何人都可以帮忙吗?

python

4
推荐指数
2
解决办法
4001
查看次数

Python-TypeError:无法在路径组件中混合字符串和字节

如下代码:

import os

directory_in_str = 'C:\\Work\\Test\\'
directory = os.fsencode(directory_in_str)

for file in os.listdir(directory):
    filename = os.fsdecode(file)
    if filename.lower().endswith(".xml"):
        with open(os.path.join(directory, filename), 'r') as handle:
            for line in handle:
                print(line)
    else:
        continue
Run Code Online (Sandbox Code Playgroud)

给我这个错误:

Traceback (most recent call last):
  File "c:\Work\balance_search2.py", line 9, in <module>
    with open(os.path.join(directory, filename), 'r') as handle:
  File "C:\ProgramData\Anaconda3\lib\ntpath.py", line 114, in join
    genericpath._check_arg_types('join', path, *paths)
  File "C:\ProgramData\Anaconda3\lib\genericpath.py", line 151, in _check_arg_types
    raise TypeError("Can't mix strings and bytes in path components") from None
TypeError: Can't mix strings and …
Run Code Online (Sandbox Code Playgroud)

python

3
推荐指数
1
解决办法
4239
查看次数

标签 统计

python ×2