cmd报错:SyntaxError: EOL while scanning string literal

dos 命令行 中输入:
  python3 -m timeit -s ‘text = “sample string”; char = “g”’ 'char in text’
报错:SyntaxError: EOL while scanning string literal(如下图)
这是因为 cmd语法 不能正确识别单引号 导致的在这里插入图片描述
解决方法: 将单引号放在双引号里面
python -m timeit -s “text = ‘sample string’; char = ‘g’” "char in text"

注: 关于 cmd 中的单双引号 问题,详见:cmd 中的单双引号

发布了13 篇原创文章 · 获赞 6 · 访问量 518

猜你喜欢

转载自blog.csdn.net/ljr_123/article/details/104868074