我正在使用 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 脚本。
- 将其命名为
script.sh
,而不是.py
。 - 在顶部添加“shebang”行:
#!/bin/bash
- 使其可执行:
chmod +x ./script.sh
- 运行它:
blainer@ubuntu:~/Desktop/convert$ ./script.sh
关于python宽度语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10198430/