在argparse中有什么方法可以解析标志[+-]a,b,c,d吗?
foo.py +s -b
Run Code Online (Sandbox Code Playgroud)
应存放在真正dest的s和虚假dest的b,很像由Windows完成attrib或Linux的chmod.
目前,我用2个独立的参数+s,并-s用store_true和store_false,分别.但它创造了一个丑陋的帮助,它列出每个标志两次(+ a&-a)
另一种解决方法是使用正则表达式手动解析扩展的arg(这在某种程度上似乎更容易并且使用自定义描述,但在此之前我只想环顾四周是否有任何使用argparse本身可以执行相同操作的东西.
我在Android应用程序中使用ScrollView具有以下XML布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="fill_parent">
<TextView.../>
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/linearLayout1">
<CheckBox ...>
<requestFocus></requestFocus>
</CheckBox>
<CheckBox ..></CheckBox>
</LinearLayout>
<ScrollView android:layout_width="match_parent" android:layout_height="wrap_content" >
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical">
<TextView android:text="Block Type:" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
<RadioGroup android:orientation="horizontal" android:id="@+id/inputType" android:layout_width="wrap_content" android:layout_height="wrap_content">
<RadioButton android:id="@+id/btCall" android:paddingRight="10px" android:text="Call" android:layout_height="wrap_content" android:layout_width="wrap_content" android:checked="true"></RadioButton>
<RadioButton android:id="@+id/btSMS" android:paddingRight="10px" android:text="SMS" android:layout_height="wrap_content" android:layout_width="wrap_content"></RadioButton>
<RadioButton android:id="@+id/btBoth" android:paddingRight="10px" android:text="Call + SMS" android:layout_height="wrap_content" android:layout_width="wrap_content"></RadioButton>
</RadioGroup>
<Button android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/chooseContactButton" android:text="Choose from contacts..."></Button>
<TextView android:text="Name:" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
<EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="textPersonName" android:id="@+id/inputName">d</EditText>
<TextView android:text="Number:" android:layout_width="wrap_content" …Run Code Online (Sandbox Code Playgroud)