最近在解析命令行参数的时候碰到python字符分割的问题,python中字符串分割默认都是在空格,但是我的参数中可能某个参数带有空格符,同时有双引号包围。
最近的python中引入了支持正则分割的shlex模块,他能很好的处理空格符的问题。如下:
>>> import shlex
>>> shlex.split('this is "a test"')
['this', 'is', 'a test']
但是我需要我写jyhon程序需要通过在Weblogic的脚本工具中运行即WLST.
程序需要支持所有的Oracle11g的weblogic环境中运行,也就是
WLST online is supported on WebLogic Server 11g Release 1 (10.3.1, 10.3.2, 10.3.3, 10.3.5, and 10.3.6
), 10.3, 10.0, 9.x, 8.1, and 7.0.
所支撑的jython版本是 Jython 2.2.1.
但是 Jython 只有在2.3版本才引入shlex
.split语法,所以原理上我不能使用这一函数。
尝试半天只能使用最古老的方法,正则表达式来解决;
jvmArgsList = [p for p in re.split("( |\\\".*?\\\"|'.*?')", jvmOptions) if p.strip()]
该方法支持命令行参数中含有被单引号或双引号包围的空格符。
比如:
jvmOptions ="-DUseSunHttpHandler=true -Dtest.dir='C:\SAS Test'"
程序能把各参数分割开来。
分享到:
相关推荐
Preserving styles using python's xlrd,xlwt
Python参考手册,官方正式版参考手册,chm版。以下摘取部分内容:Navigation index modules | next | Python » 3.6.5 Documentation » Python Documentation contents What’s New in Python What’s New In ...
A Location Privacy Preserving Approach on Road Network A Location Privacy Preserving Approach on Road Network
Privacy-preserving and communication-efficient federated learning in Internet of Things.pdf
医学磁共振重构方法,一种有效重构出高质量图像的方法。
centers over a single unified network is a big trend in the information technology industry. Extensions to 10G Ethernet are making it the most promising technology for achieving I/O consolidation. The...
privacy preserving robust data aggregation in wireless sensor networks
Minimizing matrix effects while preserving throughput in LC–MS/MS
2017 SecureML:A system for scalable privacy-preserving machine learning论文ppt
Zoneout Regularizing RNNs by Randomly Preserving Hidden Activations
In particular, we design a continuous-valued loss function that enforces a segmentation to have the same topology as the ground truth, i.e., having the same Betti number. The proposed topology-...
Multi-party computation (MPC) poses itself as a suitable option to offer the basic building block for building decentralized privacy-preserving computational frameworks. In MPC, each party has to ...
LPP: Locality Preserving Projections % Note: After applying some simple algebra, the smallest eigenvalue problem: % data^T*L*data = \lemda data^T*D*data % is equivalent to the largest eigenvalue ...
Learning a Parametric Embedding by Preserving Local Structure. In Proceedings of the Twelfth International Conference on Artificial Intelligence & Statistics (AI-STATS), JMLR W&CP 5:384-391, 2009. ...
A Voronoi-Based Location Privacy-Preserving Method for Continuous Query in LBS
Locality Preserving Projections代码
A Privacy-Preserving Classifier in Statistic Pattern Recognition
SLOMS: A Privacy Preserving Data Publishing Method for Multiple Sensitive Attributes Microdata
PMDP: A framework for preserving multiparty data privacy in cloud computing
车联网(IoV)中的隐私保护:一种基于区块链的群组领导影子方案-Preserving Privacy in Internet