python - 如何将可读(r)添加到字符串?
问题描述
我在使用文件路径时遇到问题,因为它包含\
所以我必须添加r
或交换\
与 double \
。
问题是我想将 添加r
到存储在变量中的字符串而不手动执行(我得到的变量包含带有 的路径input()
)。我怎么能那样做?
编辑:这是代码:
#The path of my directory
direc =str(input())
list = os.listdir(direc) #This gives me the name of all the files in my directory
cap = cv2.VideoCapture(the path of my directory \list[0]) #path of the file, this is where I have trouble
length = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
print(length)
解决方案
推荐阅读
- mysql - RDS上lambda函数与MySQL的连接问题
- couchbase - 使用嵌套查询检索键上的文档
- python-3.x - 在 ubuntu amazon 实例中导入 cv2 模块时出错
- java - 使用 GUI 元素的线程池中的线程数
- javascript - 使用 input[type="radio"] 验证总是返回 false
- grpc - improbable-eng/grpc-web 响应关闭,没有标题
- codenameone - 从代码访问 css 自定义主题常量
- r - 变异只适用于第一列的值
- web-services - 如何在 Flutter 中使用 FedEx Web Services
- java - Javafx SimpleStringProperty 反序列化抛出 IllegalStateException: 未读块数据