Chinaunix

标题: 单引号和双引号在python 是不是没区别的啊? [打印本页]

作者: wubulen    时间: 2006-11-30 05:20
标题: 单引号和双引号在python 是不是没区别的啊?
如题,用了好久,好像没啥规则。在此证实一下。
作者: aikunoracle    时间: 2006-11-30 08:43
确实没有区别的啊
作者: 海天    时间: 2006-11-30 09:10
其实还是有点区别的,如下面的句子:print 'It's a test' 这时如果用单引号就会出错,如果用双引号就没有问题。
作者: alexru    时间: 2006-12-03 17:22
好像没区别,都表字符串
作者: nicozhou    时间: 2009-08-05 09:48
标题: 回复 #3 海天 的帖子
版主莫怪啊,今天在看书的时候还奇怪,试了一下,发现有得时候是没有区别的。

=================================
这个就没有区别。

  1. >>> li
  2. ['abc', 'small', 'all', 'not', 'is', 'line', 'to', ['', '', '']]
  3. >>> li.remove('small')
  4. >>> li
  5. ['abc', 'all', 'not', 'is', 'line', 'to', ['', '', '']]
  6. >>> li.remove("all")
  7. >>> li
  8. ['abc', 'not', 'is', 'line', 'to', ['', '', '']]
  9. >>>
复制代码

作者: ntluking    时间: 2015-02-09 13:55
print'It\'s a test'这样也是没问题的




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2