Python用户输入文件路径

时间:2016-10-03 19:58:41

标签: python

我正在开发一个简单的项目,需要用户输入程序路径并转到此路径 在这里,我在OSX上Worte:

from pathlib import Path

def main():
    user_input_path = Path(input())

像这样调试

>>> /Users/akrios/Desktop/123
SyntaxError: invalid syntax

1 个答案:

答案 0 :(得分:0)

<input highlight type="text" maxlength="32" ng-pattern="/^[0-9]+(\.[0-9]{1,4})?$/" step="0.0001" class="form-control input-config" name="orifice_size" id="orifice_size" ng-max="model.asset.line_size"ng-model="model.asset.orifice_size" > module.directive('highlight', function() { return { restrict: 'A', require: 'ngModel', scope: { ngModel: "=" }, link : function($scope, element, attributes, ctrl){ $scope.$watch('ngModel', function (newVal, oldVal, scope) { if (scope.$parent.copyModel !== undefined && scope.$parent.copyModel[element[0].id] !== undefined && (newVal !== scope.$parent.copyModel[element[0].id] )) { element.addClass('input-change'); console.log(element) } else{ element.removeClass('input-change'); } }); } }; }); 函数读入输入,然后尝试解析它,好像它是Python表示法中的东西。相反,使用input()函数,它不会解析任何内容并将输入作为字符串返回。