python - Is there a way to write single backslash within lists?
问题描述
enter image description here is there a way to print single backslash within list?
解决方案
关于你问题的第一个版本,我写了这个:
首先,这个表达式
x='\'
在 Python 中的 Python 中是不正确的。您应该这样说:x='\\'
,因为反斜杠是python中的特殊字符。其次,试试这个:
l=['\\'] print(l)
这将打印:['\\']
但是当你执行 this: 时
print(l[0])
,它会渲染 this'\'
。所以基本上,这['\\']
是在列表中打印反斜杠的方法。
推荐阅读
- java - 我可以为 OpenGL 中的静态对象推送一次矩阵吗?
- flutter - 在列表视图中滚动地图时如何避免滚动列表视图
- python - 如何在 Scikit Learn 中预测新文档的类别
- javascript - 如何将“isTrusted”设置为 true(模拟 MouseEvent)?
- scala - 如何管理函数式编程中的状态层次结构?
- http-headers - `content-security-policy: default-src https:;` 以内联 1:1 阻止资源加载
- reactjs - 在浏览器中获取 refresh_token 时遇到问题。无法读取 XML 响应
- c# - 将 IntPtr 作为函数的参数传递会导致内存泄漏吗?
- racket - 如何“要求”没有#lang 标题行的 Racket 模块?
- windbg - 是否可以在 windbg 中调用 win32 调用?