在 Python 3.x 中做了一个改变,在 What’s New In Python 3.0 中有如下描述: “列表推导不再支持 [… for var in item1, item2, …] 这样的语法。使用 [… for var in (item1, item2, …)] 代替。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#!/usr/bin/python2 >>> i = 1 >>> print 'before: i =', i before: i = 1 >>> print 'comprehension: ', [i for i in range(5)] comprehension: [0, 1, 2, 3, 4] >>> print 'after: i =', i after: i = 4
#!/usr/bin/python3 >>> i = 1 >>> print('before: i =', i) before: i = 1 >>> print('comprehension:', [i for i in range(5)]) comprehension: [0, 1, 2, 3, 4] >>> print('after: i =', i) after: i = 1
try:#python2 from UserDict import UserDict #建议按照python3的名字进行import from UserDict import DictMixin as MutableMapping except ImportError:#python3 from collections import UserDict from collections import MutableMapping
@echo off set PATH=E:\Simulation\x64\Release\;%PATH%; E: cd E:\Simulation\x64\Release\ cd BlueSimu start FlightSimServer.exe cd ../RedSimu start FlightSimServer.exe cd .. start Simulation.exe start Simulation.exe pause
示例2:
1 2 3 4 5 6 7 8 9 10 11 12 13
:: 定义变量 set dataset=j:\tensorflow\dataset\LSOTB-TIR\Training Dataset set imagedir=%dataset%\LSOTB-TIR_TrainingData\TrainingData\TIR_training_004\bird_001 set xmldir=%dataset%\LSOTB-TIR_TrainingData\Annotations\TIR_training_004\bird_001 set labelpath=j:\tensorflow\workspace\training_demo\annotations\label_map.pbtxt set outputdir=j:\tensorflow\workspace\training_demo\annotations\infrared_train_bird_004_001 set process_script=j:\tensorflow\scripts\preprocessing\generate_pascal_tfrecord.py
:: 调用tfrecord脚本程序, for循环,字符串截取,字符串拼接,路径空格处理 for /L %%i in (1,1,7) do python %process_script% -i "%imagedir:~0,-1%%%i" -x "%xmldir:~0,-1%%%i" -l %labelpath% -o %outputdir:~0,-1%%%i.record :: for /L %%i in (10,1,16) do python %process_script% -i "%imagedir:~0,-2%%%i" -x "%xmldir:~0,-2%%%i" -l %labelpath% -o %outputdir:~0,-2%%%i.record
上述三种工具的比较请参阅http://strong-pm.io/compare/。其中,StrongLoop Process Manager无法在Windows平台工作,再综合比较PM2和Forever,由于Forever没有操作系统自启动的脚本,故选择PM2作为Windows平台Node.js应用的进程管理器。
pm2-windows-service基于 node-windows将PM2注册为Windows服务,从而实现自启动。pm2-windows-startup则基于start-on-windows-boot在注册表中将PM2设为自启动程序,从而实现自启动。两种方案经测试,只有pm2-windows-startup在Windows Server 2012上可行,故选择pm2-windows-startup作为解决Node.js应用开机自启动的方案。