gpt4 book ai didi

python - 如何在字符串变量中存储单个\?

转载 作者:行者123 更新时间:2023-12-04 08:19:16 26 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





Quoting backslashes in Python string literals [duplicate]

(5 个回答)



How to print a single backslash?

(5 个回答)


8 个月前关闭。



file_name = file_path.split('\')
给我一个错误,因为 \'是在python中表示单引号。
我想使用单个反斜杠拆分文件名。

最佳答案

使用双 \ :

file_name = file_path.split('\\')

关于python - 如何在字符串变量中存储单个\?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65567601/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com