string_join.py 1013 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/usr/bin/env python
  2. # -*- encoding: utf-8 -*-
  3. '''
  4. @Author : liuyuqi
  5. @Contact : liuyuqi.gov@msn.cn
  6. @Time : 2019/08/11 09:47:45
  7. @Version : 1.0
  8. @License : (C)Copyright 2019
  9. @Desc : 字符串拼接
  10. '''
  11. url1 = "https://juejin.im/pins/topic/5abcaa67092dcb4620ca335c?page="
  12. tmp = 1
  13. def t1():
  14. '''
  15. join 字符串链接。。。垃圾!!
  16. '''
  17. print(url1.join(str(tmp)))
  18. print("".join([url1, str(tmp)]))
  19. print("ni hao ya".join("wo bu hao"))
  20. try:
  21. print("".join([url1, tmp]))
  22. except Exception as e:
  23. print(e)
  24. t1()
  25. def t2():
  26. '''
  27. , 逗号字符串链接,垃圾!!
  28. '''
  29. a1 = url1, tmp
  30. print(a1)
  31. t2()
  32. def t3():
  33. '''
  34. +,加号字符串链接,垃圾!!
  35. '''
  36. try:
  37. a2 = url1+tmp
  38. print(a2)
  39. except Exception as e:
  40. print(e)
  41. print(url1+str(tmp))
  42. t3()
  43. def t4():
  44. '''
  45. , 逗号字符串链接,垃圾!!
  46. '''
  47. res = '{0}{1}'.format(url1, tmp)
  48. print(res)
  49. t4()