Thoughts, stories and ideas.

翻译 2014年以前 关于

28 Dec 2009

If s and t are both strings, some Python implementations such as CPython can usually perform an in-place optimization for assignments of the form s = s + t or s += t. When applicable, this optimization makes quadratic run-time much less likely. This optimization is both version and implementation dependent. For performance sensitive code, it is preferable to use the str.join() method which assures consistent linear concatenation performance across versions and implementations.


There are six sequence types: strings, Unicode strings, lists, tuples, buffers, and xrange objects.

For other containers see the built in dict and set classes, and the collections module.


   for root, dirs, files in os.walk('/media/cdrom0'):
      export+="\n %s;%s;%s" % (root,dirs,files)
   open('TokyoHot1', 'w').write(export)
   for root, dirs, files in os.walk('/media/cdrom0'):
        export.append("\n %s;%s;%s" % (root,dirs,files))
    open('TokyoHot2', 'w').write(''.join(export))

翻译 2014年以前 关于