[英]Python user input file path
I am working on an easy project which requires user input a path for program and goes to this path Here, I Worte on OSX: 我正在做一个简单的项目,该项目需要用户输入程序路径,然后转到该路径。
from pathlib import Path
def main():
user_input_path = Path(input())
And debug like this 像这样调试
>>> /Users/akrios/Desktop/123
SyntaxError: invalid syntax
The input()
function reads in the input, and then tries to parse it as if it's something in Python notation. input()
函数读取输入,然后尝试将其解析为Python表示法。 Instead, use the raw_input()
function, it does not parse anything and returns the input as a string. 而是使用
raw_input()
函数,它不解析任何内容,并以字符串形式返回输入。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.