Is this a bug of str.join?

Stefan Behnel stefan_ml at behnel.de
Wed Feb 16 07:34:27 CET 2011


fireinice, 16.02.2011 07:24:
> Hi, all
> I'm just working around to generate some fake file for parsing. and I
> notice some weired thing happen.
>      time = str(random.randint(1000000000000000, 9999999999999999))
>      s_id = str(random.randint(1000000000000000, 9999999999999999))
>      p_id = str(random.randint(1000000000000000, 9999999999999999))
>      a_id = str(random.randint(1000000000000000, 9999999999999999))
>      s = "test"
>      a = [time, s_id, p_id, a_id, s]
>      print '\t'.join(a)
>
> the output is:
> 3107903582321032	6101282916386924	719897196119318	1780339444980186test
>
> you can notice that there is no tab between a_id and s

Likely just a presentation problem in your terminal. Try with a single 
space instead of tabs and see the difference.

Stefan




More information about the Python-list mailing list