使用Python pathlib获取没有文件名的文件的绝对路径

问题描述

我要替换file_location = os.path.abspath(os.path.dirname(__file__))pathlib一起使用,以获取不带文件名的文件的最佳路径
使用directorypath = pathlib.Path(__file__).resolve() 给我绝对路径+文件
如何在没有文件名的情况下获取绝对路径

解决方法

您可以使用'.parent': TextField( onChanged: (newValue) { if (newValue.length > 5) { // test for your condition setState(() { _color = Colors.red; // change the color }); } else { setState(() { _color = Colors.blue; // change the color if the condition is not met }); } },),
Path.parent