以开头的输入出现Python输入错误/

以开头的输入出现Python输入错误/,python,python-2.7,Python,Python 2.7,我是python新手,我正在编写一个python脚本,可以从目录中读取json文件并处理它。为此,我向用户询问文件名 file_dir = input("Please enter the directory COMPLETE path where all dialog json files are placed: ") files = listdir(str(file_dir)) 但是,当我输入路径时会出现错误 Please enter the directory COMPLETE path

我是python新手,我正在编写一个python脚本,可以从目录中读取json文件并处理它。为此,我向用户询问文件名

file_dir = input("Please enter the directory COMPLETE path where all dialog json files are placed: ")

files = listdir(str(file_dir))
但是,当我输入路径时会出现错误

Please enter the directory COMPLETE path where all dialog json files are placed: /Users/monideepde/Documents/Sanofi/EnglishDialogs
Traceback (most recent call last):
  File "/Users/monideepde/PycharmProjects/KoreDialogLanguageConverter/Converter.py", line 4, in <module>
    file_dir = input("Please enter the directory COMPLETE path where all dialog json files are placed: ")
  File "<string>", line 1
    /Users/monideepde/Documents/Sanofi/EnglishDialogs
    ^
SyntaxError: invalid syntax

Process finished with exit code 1
请输入放置所有对话框json文件的目录完整路径:/Users/monidepde/Documents/Sanofi/EnglishDialogs
回溯(最近一次呼叫最后一次):
文件“/Users/monideepde/PycharmProjects/KoreDialogLanguageConverter/Converter.py”,第4行,在
file_dir=input(“请输入放置所有对话框json文件的目录完整路径:”)
文件“”,第1行
/用户/监视器/文档/赛诺菲/英语对话
^
SyntaxError:无效语法
进程已完成,退出代码为1
奇怪的是,当我用双引号括起我的路径时,没有看到这个错误。如果有人知道我为什么会犯这个错误,你能和我分享一下吗

附言:我正在使用Python2.7

感谢在Python2.x中,
input()
尝试将输入作为Python表达式运行。改为使用
raw\u input()
——它返回一个不带求值的字符串

file_dir = raw_input("Please enter the directory COMPLETE path where all dialog json files are placed: ")
在Python2.x中,
input()
尝试将输入作为Python表达式运行。改为使用
raw\u input()
——它返回一个不带求值的字符串

file_dir = raw_input("Please enter the directory COMPLETE path where all dialog json files are placed: ")

尝试使用原始输入而不是输入,因为您使用的是python2.7。原始输入(“输入目录”)


要使用目录,请查看操作系统模块。

尝试使用原始输入而不是输入,因为您使用的是python2.7。原始输入(“输入目录”)


对于使用目录,请查看操作系统模块。

非常感谢您的回复非常感谢您的回复非常感谢您的回复非常感谢您的回复非常感谢您的回复非常感谢您的回复