python宽度语法错误

标签 python linux syntax

我正在使用 python 2.7.2 运行 Ubuntu。

脚本

python \
/home/blainer/Desktop/convert/converter.py \
/home/blainer/Desktop/convert/urban.shp \
/home/blainer/Desktop/convert/result.js \
--width 900 \
--country_name_index 4 \
--where "ISO = 'USA'" \
--codes_file /home/blainer/Desktop/convert/codes-en.tsv \
--insets '[{"codes": ["US-AK"], "width": 200, "left": 10, "top": 370}, {"codes": ["US-HI"], "width": 100, "left": 220, "top": 400}]' \
--minimal_area 4000000 \
--buffer_distance -3000 \
--simplify_tolerance 1000 \
--longtitude0 10w \
--name us

错误

blainer@ubuntu:~/Desktop/convert$ python script.py
File "script.py", line 5
--width 900 \
          ^
SyntaxError: invalid syntax

最佳答案

那不是 Python 脚本,它是运行 Python 的 shell 脚本。

  1. 将其命名为 script.sh,而不是 .py
  2. 在顶部添加“shebang”行:#!/bin/bash
  3. 使其可执行:chmod +x ./script.sh
  4. 运行它:blainer@ubuntu:~/Desktop/convert$ ./script.sh

关于python宽度语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10198430/

相关文章:

c++ - if 语句的一个分支不能只是一个声明?

xml - 幻象错误 "error parsing XML: unbound prefix"

Mac 上的 Python 版本

linux - 在 raspbian linux 上使用 ffmpeg 连接多个(自生成的)视频

c++ - Cout 给出了一个奇怪的输出

linux - Linux中什么不是文件

linux - 我可以在 cron 文件中添加源语句吗?

python - 重定向到同一页面后,Flask Flash 消息不显示

python - 无法转换为 panda3d 的 Egg 文件

Python socket.recv 异常