为什么此Visual Studio代码会引发SyntaxError?

时间:2019-07-13 17:09:22

标签: python string

仅在VSC中而不是PyCharm中出现语法错误。

<html>
<form method="post">
<input name="url" size="50" />
<input name="submit" type="submit" />
</form>
<?php

// maximum execution time in seconds
set_time_limit (24 * 60 * 60);

if (!isset($_POST['submit'])) die();


// folder to save downloaded files to. must end with slash
$destination_folder = 'downloads/';

$url = $_POST['url'];
$newfname = $destination_folder . basename($url);

$file = fopen ($url, "rb");
if ($file) {
  $newf = fopen ($newfname, "wb");

  if ($newf)
  while(!feof($file)) {
    fwrite($newf, fread($file, 1024 * 8 ), 1024 * 8 );
  }
}

if ($file) {
  fclose($file);
}

if ($newf) {
  fclose($newf);
}

?>
</html> 

例外:

  

文件“ /var/folders/4p/bxqjj1910_vd05mk0cywnrxr0000gn/T/tempCodeRunnerFile.python”,第2行,
      a = f“ Hello World {user}”
                            ^
  SyntaxError:语法无效

1 个答案:

答案 0 :(得分:-1)

我认为您的Python版本较旧。此f字符串在Python 3.6或更高版本中可用。转到此链接并升级您的python版本。并设置环境变量的路径。

https://www.python.org/downloads/