Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/320.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中查找XNATPy对象的本地名称_Python_Python 3.x_Xnat - Fatal编程技术网

在Python中查找XNATPy对象的本地名称

在Python中查找XNATPy对象的本地名称,python,python-3.x,xnat,Python,Python 3.x,Xnat,我正在试用XNATpy,并且正在访问计算机上未本地安装的文件。如何获取正在访问的文件对象的名称,例如“1.3.6.1…-18s1eb2.dcm” 我的代码: file_obj = connection.projects['project'].subjects['S'].experiments['EXP'].scans['T1'].resources['DICOM'].files[0] print (file_obj) 打印对象时的输出: <FileData 1.3.6.1...-18

我正在试用XNATpy,并且正在访问计算机上未本地安装的文件。如何获取正在访问的文件对象的名称,例如“1.3.6.1…-18s1eb2.dcm”

我的代码:

file_obj = connection.projects['project'].subjects['S'].experiments['EXP'].scans['T1'].resources['DICOM'].files[0] 

print (file_obj)
打印对象时的输出:

<FileData 1.3.6.1...-18s1eb2.dcm (1.3.6.1...-18s1eb2.dcm)>

您可以
打印(dir(file_obj))
以查看属性是什么there@OneCricketeer我已经更新了帖子!文件中提到了
外部uri
。这就是你要找的名字吗?
path
uri
看起来也很合适。请注意,它不是中的Python文件对象。
print(dir(file_obj))

['SECONDARY_LOOKUP_FIELD', '_CONTAINED_IN', '_DISPLAY_IDENTIFIER', '_HAS_FIELDS', '_XSI_TYPE', '__abstractmethods__', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '__xsi_type__', '_abc_impl', '_cache', '_caching', '_fieldname', '_fields', '_overwrites', '_parent', '_path', '_uri', '_xnat_session', 'caching', 'cat_id', 'clearcache', 'collection', 'data', 'del_', 'delete', 'digest', 'download', 'download_stream', 'external_uri', 'fieldname', 'file_content', 'file_format', 'file_size', 'file_tags', 'full_data', 'fulldata', 'fulluri', 'get', 'get_object', 'id', 'logger', 'mset', 'open', 'parent', 'path', 'query', 'set', 'size', 'uri', 'xnat_session', 'xpath']