concatenation TypeError: sequence item 0: expected str instance, list found
concatenation TypeError: sequence item 0: expected str instance, list found
当我想连接到我想更改的层的地址时,我的脚本出现了问题。所以我使用这个脚本:
import glob
import arcpy
import pathlib
import os
import re
print("ouverture des droits")
users = ['geom01', 'geom02']
targetPattern = r"C:\Users\**\AppData\Roaming\Esri\ArcGISPro\Favorites\TEST@geom06.sde"
target = glob.glob(targetPattern)
print(target)
filename = r'\test.geom06.part_voiture'
joiend = [target,filename]
for ready in joiend:
print(''.join([target,r'\test.geom06.part_voiture']))
print(ready)
couche_voiture = ready
for i in users:
arcpy.ChangePrivileges_management(couche_voiture, i, "GRANT", "AS_IS")
message = "privilege modifié pour " + i + "sur finess"
print(message)
但是当我执行脚本时,我收到了这条消息:
"C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe" C:/Users//Documents/tian.py
ouverture des droits
Traceback (most recent call last):
File "C:/Users//Documents/tian.py", line 20, in <module>
print(''.join([target,r'\test.geom06.part_voiture']))
TypeError: sequence item 0: expected str instance, list found
['C:\Users\\AppData\Roaming\Esri\ArcGISPro\Favorites\TEST@geom06.sde']
Process finished with exit code 1
你知道我该如何解决吗?
target
是一个列表,因此您也需要在其上使用 join
import glob
import arcpy
import pathlib
import os
import re
print("ouverture des droits")
users = ['geom01', 'geom02']
targetPattern = r"C:\Users\**\AppData\Roaming\Esri\ArcGISPro\Favorites\TEST@geom06.sde"
target = glob.glob(targetPattern)
print(target)
filename = r'\test.geom06.part_voiture'
joiend = [target,filename]
for ready in joiend:
# JOIN TARGET
print(''.join(["\".join(target),r'\test.geom06.part_voiture']))
print(ready)
couche_voiture = ready
for i in users:
arcpy.ChangePrivileges_management(couche_voiture, i, "GRANT", "AS_IS")
message = "privilege modifié pour " + i + "sur finess"
print(message)
当我想连接到我想更改的层的地址时,我的脚本出现了问题。所以我使用这个脚本:
import glob
import arcpy
import pathlib
import os
import re
print("ouverture des droits")
users = ['geom01', 'geom02']
targetPattern = r"C:\Users\**\AppData\Roaming\Esri\ArcGISPro\Favorites\TEST@geom06.sde"
target = glob.glob(targetPattern)
print(target)
filename = r'\test.geom06.part_voiture'
joiend = [target,filename]
for ready in joiend:
print(''.join([target,r'\test.geom06.part_voiture']))
print(ready)
couche_voiture = ready
for i in users:
arcpy.ChangePrivileges_management(couche_voiture, i, "GRANT", "AS_IS")
message = "privilege modifié pour " + i + "sur finess"
print(message)
但是当我执行脚本时,我收到了这条消息:
"C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe" C:/Users//Documents/tian.py
ouverture des droits
Traceback (most recent call last):
File "C:/Users//Documents/tian.py", line 20, in <module>
print(''.join([target,r'\test.geom06.part_voiture']))
TypeError: sequence item 0: expected str instance, list found
['C:\Users\\AppData\Roaming\Esri\ArcGISPro\Favorites\TEST@geom06.sde']
Process finished with exit code 1
你知道我该如何解决吗?
target
是一个列表,因此您也需要在其上使用 join
import glob
import arcpy
import pathlib
import os
import re
print("ouverture des droits")
users = ['geom01', 'geom02']
targetPattern = r"C:\Users\**\AppData\Roaming\Esri\ArcGISPro\Favorites\TEST@geom06.sde"
target = glob.glob(targetPattern)
print(target)
filename = r'\test.geom06.part_voiture'
joiend = [target,filename]
for ready in joiend:
# JOIN TARGET
print(''.join(["\".join(target),r'\test.geom06.part_voiture']))
print(ready)
couche_voiture = ready
for i in users:
arcpy.ChangePrivileges_management(couche_voiture, i, "GRANT", "AS_IS")
message = "privilege modifié pour " + i + "sur finess"
print(message)