如何删除逗号和括号

时间:2017-07-18 09:26:29

标签: python python-2.7 cx-oracle

这是我使用Cx_Oracle lib

的输出
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#e6e6e6"
    android:orientation="vertical"
    android:padding="1dp">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

<LinearLayout
    android:orientation="vertical"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
    <TextView

        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:background="#868585"
        android:padding="0dp"
        android:text="Basic Information"
        android:textColor="#ffffff" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="9"
                app:srcCompat="@mipmap/ic_launcher" />

            <TextView
                android:id="@+id/textView7"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:text="Addhhhhhhhhhhhhhhhhhhvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhress" />
        </LinearLayout>


        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="@android:color/darker_gray" />


    </LinearLayout>
</LinearLayout>
</ScrollView>

</LinearLayout>

如何删除&#39;&#39; ,和()。这是一个字符串。

4 个答案:

答案 0 :(得分:1)

它只是一个元组内的值!如果你想直接值只是访问它,就像你通常使用列表或元组一样。即('DATABASE3',)[0]

答案 1 :(得分:0)

试一试:

a = ('DATABASE2',)
print a[0]

答案 2 :(得分:0)

import re 
ans_con=(str(d))
print re.sub(r'\W', '', ans_con)

答案 3 :(得分:0)

假设我有

a = ('DATABASE2',)

检查类型:

type(a)

会给您<type 'tuple'>

因此您可以将其打印为数组:

print a[0]

或者,如果您想将输出捕获为字符串,只需使用:

print str(a[0])

我认为我们不需要在这里应用任何复杂的正则表达式逻辑。