Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/366.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在字符串中的特定位置插入字符_Python_Python 3.x_Insert_Jupyter Notebook - Fatal编程技术网

Python 在字符串中的特定位置插入字符

Python 在字符串中的特定位置插入字符,python,python-3.x,insert,jupyter-notebook,Python,Python 3.x,Insert,Jupyter Notebook,我有以下问题。我想在每一行后面插入以下特定列中的字符串 The Bahamas (All locations)Bermuda (All locatins)Romania (Cluj)Bulgaria (All locations) 我的想法是在同一列、同一表的多行上有这种类型的字符串。请在这个问题上帮助我 我希望: The Bahamas (All locations),Bermuda (All locatins),Romania (Cluj),Bulgaria (All locations)

我有以下问题。我想在每一行后面插入以下特定列中的字符串

The Bahamas (All locations)Bermuda (All locatins)Romania (Cluj)Bulgaria (All locations)
我的想法是在同一列、同一表的多行上有这种类型的字符串。请在这个问题上帮助我

我希望:

The Bahamas (All locations),Bermuda (All locatins),Romania (Cluj),Bulgaria (All locations), 
为了以我需要的方式拆分信息。

使用str.replace:

In [1]: s1 = 'The Bahamas (All locations)Bermuda (All locatins)Romania (Cluj)Bulgaria (All locations)'

In [2]: s2 = s1.replace(')', '),')

In [3]: s2
Out[3]: 'The Bahamas (All locations),Bermuda (All locatins),Romania (Cluj),Bulgaria (All locations),'
使用str.replace:

In [1]: s1 = 'The Bahamas (All locations)Bermuda (All locatins)Romania (Cluj)Bulgaria (All locations)'

In [2]: s2 = s1.replace(')', '),')

In [3]: s2
Out[3]: 'The Bahamas (All locations),Bermuda (All locatins),Romania (Cluj),Bulgaria (All locations),'

法罗群岛所有位置Guernsey所有位置阿尔巴尼亚所有位置Sandora所有位置奥兰群岛所有位置Bulgaria所有位置这是我的专栏的外观column name=国家请告诉我如何使用,不要写s1=String->s1=Column name,然后为Column做所有这些工作,你是说pands列吗?熊猫不在标签里,所以我没有得到它。对于熊猫,请使用法罗群岛所有位置Guernsey所有位置阿尔巴尼亚所有位置Sandora所有位置奥兰群岛所有位置Bulgaria所有位置这是我的专栏的样子column name=Country请告诉我如何使用,不要写s1=String->s1=Column name,然后为Column做所有这些工作,你是说pands列吗?熊猫不在标签里,所以我没有得到它。对于[1]:df['column']=df['column']].str.replace,“我在仔细搜索后解决了这个问题在[1]:df['column']=df['column'].str.replace中,”我在仔细搜索后解决了这个问题