Python中文
首页
教程
问答
标签
搜索
登录
注册
如何将文件目录作为方法参数传递?
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>这里的代码是我首先读取文件配置,然后我需要将目录传递到称为ednotes的方法中_提取器。获取注释()</p> <pre><code> from preprocessing import ednotes_extractor csf_config_txt = open("..\CFS_Config.txt", "r") file_list = [] root_dir = "" edn_txt = "" pcr_txt = "" for line in csf_config_txt: file_list.append(line) if "Folder Path = " in file_list[0]: root_dir = str(file_list[0]) root_dir = root_dir.replace("Folder Path = ", "") root_dir = root_dir.replace("\n", "") if "ED Notes = " in file_list[1]: root_dir = str(file_list[1]) root_dir = root_dir.replace("ED Notes = ", "") root_dir = root_dir.replace("\n", "") if "Patient Care Record = " in file_list[2]: root_dir = str(file_list[2]) root_dir = root_dir.replace("Patient Care Record = ", "") root_dir = root_dir.replace("\n", "") print(file_list[2]) def convert_txt(choices): if(choices == 1): #I would like to pass a directory in this method called theednotes_extractor ednotes_extractor.get_ednotes(str2=file_list[1]) elif(choices==2): print("Hi") </code></pre>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>列表理解就可以了。它将打开列表列表并将其放入新列表中。你知道吗</p> <pre><code>flat_list = [item for sublist in arr_cat for item in sublist] arr_cat = flat_list </code></pre>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
Django:。是不是“超级用户”字段不起作用
2 回答
Django:'DeleteQuery'对象没有属性'add'
9 回答
Django:'ModelForm'对象没有属性
5 回答
Django:'python manage.py runserver'返回'TypeError:'WindowsPath'类型的对象没有len()
6 回答
Django:'Python管理.pysyncdb'不创建我的架构表
6 回答
Django:'Python管理.py迁移“耗时数小时(和其他奇怪的行为)
4 回答
Django:'readonly'属性在我的ModelForm上不起作用
5 回答
Django:'RegisterEmployeeView'对象没有属性'object'
2 回答
Django:'str'对象没有属性'get'
7 回答
Django:'创建' 不能被指定为Order模型表单中的值,因为它是一个不可编辑的字段
3 回答
Django:“'QuerySet'类型的对象不是JSON可序列化的”
4 回答
Django:“'utf8'编解码器无法解码位置19983中的字节0xe9:无效的连续字节”,加载临时文件时
5 回答
Django:“<…>”需要有一个字段“id”的值,然后才能使用这个manytomy关系
4 回答
Django:“AnonymousUser”对象没有“get_full_name”属性
1 回答
Django:“ascii”编解码器无法解码位置1035中的字节0xc3:序号不在范围内(128)
5 回答
Django:“BaseTable”对象不支持索引
3 回答
Django:“collections.OrderedDict”对象不可调用
9 回答
Django:“Country”对象没有属性“all”
7 回答
Django:“Data”对象没有属性“save”
8 回答
Django:“datetime”类型的对象不是JSON serializab
2 回答