连接类型错误:序列项 0:预期的 str 实例,找到列表

发布于 2025-01-19 20:11:18 字数 1599 浏览 0 评论 0原文

当我想连接到我想要更改的层的地址时,我的脚本遇到了问题。所以我使用这个脚本:

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\[email protected]"
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\\[email protected]']

Process finished with exit code 1

你知道我该如何解决这个问题吗?

i've got a problem with my script when i want to concatenate to an address the layer i want to change. So i use this Script:

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\[email protected]"
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)

but when i execute the script i've got this 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\\[email protected]']

Process finished with exit code 1

do you know how i can resolve that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青春有你 2025-01-26 20:11:18

Target是一个列表,因此您也需要使用加入

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\[email protected]"
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)

target is a list so you need to use join on it too

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\[email protected]"
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)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文