How do you use the Piton 3 modules?



  • I recently decided to download my python 3 (beet 2) and faced a problem: I can't use the split from string module.

    import string
    song = "The rain in Spain..."
    string.split(song)
    

    Traceback (most recent call last): File "<pyshell#3>", line 1, in <module> string.split(song) AttributeError: 'module' object has no attribute 'split'

    And in principle, I can't use the rest of the team either! I've been working on a pie two.



  • There she is now. http://docs.python.org/dev/library/string.html#module-string in this module. Now it's right to write:

    import string
    song = "The rain in Spain..."
    print(song.split())
    

    And everything works properly.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2