python - Python字符串嵌套在字符串下
问题描述
当我运行下面的代码行时,我得到以下结果:
>>> a = ''' this " is what \"is 'needed' \" Please " '''
' this " is what "is \'needed\' " Please " '
我希望输出为:
' this " is what "is 'needed' " Please " '
问题正在'
被\'
. 任何人都可以提出解决此问题的方法吗?
解决方案
你只需要打印你的字符串:
a = ''' this " is what \"is 'needed' \" Please " '''
print(a)
输出:
this " is what "is 'needed' " Please "
或者,如果您真的想要外部引号:
print("'" + a + "'")
输出:
' this " is what "is 'needed' " Please " '
推荐阅读
- ibm-mobilefirst - 如何从 MFP 8.0 中的 java 适配器异步调用 javascript 适配器?
- php - 如何在 PHP 中解压缩之前在 JavaScript 中压缩的数据
- filter - 如何使用流和 flatMap 过滤数据?
- nginx - Nginx:13:权限被拒绝,尽管权限设置正确
- google-app-engine - Google App Engine 中的实时双向通信
- node.js - 在 AWS ElasticBeanstalk 中启动 Node.js 容器的权限错误
- node.js - 用于在不同目录中编译的 TypeScript API
- node.js - Scss/Sass webpack/项目设置不工作
- jquery - 不可能的?想通过电子邮件动态更改我域上的 iframe 源
- ios - 从 Firebase 快照保存/检索数据