Python, day1, and python

Source: Internet
Author: User

Python, day1, and python

  1. # There is no single character operation in python, only string functions
  2. >>> S = "www.google.com"
  3. >>> S
  4. 'Www .google.com'
  5. >>> S. split ('.') # Cut all without Parameters
  6. ['Www ', 'Google', 'com ']
  7. >>> S. split ('.', 1) # Separate once
  8. ['Www ', 'Google. com']
  9. >>> S. split ('.') [1] # extract the first string separated '.'
  10. 'Google'
  11. >>> S. split ('.',-1) # If the value is smaller than 0, all slices are cut.
  12. ['Www ', 'Google', 'com ']
  13. >>> S1, s2, s3 = s. split ('.', 2) # values of s1, s2, and s3 are assigned to obtain the cut parts.
  14. >>> S1
  15. 'Www'
  16. >>> S2
  17. 'Google'
  18. >>> S3
  19. 'Com'
  20. >>> S = ''' call # Cut line breaks!
  21. Me
  22. Baby '''
  23. >>> S
  24. 'Call \ nme \ nbaby'
  25. >>> Print s # print Display Effect
  26. Call
  27. Me
  28. Baby
  29. >>> S. split ('\ n ')
  30. ['Call', 'me', 'baby']
  31. >>> S = "hello world! <[Www.google.com]> byebye "# classic example
  32. >>> S
  33. 'Hello world! <[Www.google.com]> byebye'
  34. >>> S. split ('[') [1]. split (']') [0]
  35. 'Www .google.com'
  36. >>> S. split ('[') [1]. split (']') [0]. split ('.')
  37. ['Www ', 'Google', 'com ']

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.