使用pytest的钩子函数 conftest.py文件 def pytest_collection_modifyitems(items): for item in items: item.name = item.name.encode('utf-8').decode('unicode_escape') item._nodeid = item._nodeid.encode('utf-8').decode('unicode_escape')