元组(tuple)

  元组其实跟列表差不多,也是存一组数,与列表相比,元组一旦创建,便不能再修改,所以又叫只读列表。

 语法:

  1. names = ("Wuchunwei","Yangmengmeng","Lvs")
  2.  
  3. #元组只有2个方法,一个是count,一个是index
  1. >>> tuple1 = (,,'',,'')
  2. >>> print (tuple1[])
  3.  
  4. >>> print (tuple1[-])
  5.  
  6. >>> print (tuple1[:]) #元组也可以进行切片操作。对元组切片可以得到新的元组。
  7. (, '')
  8. >>>

枚举

  1. >>> for i,v in enumerate(range(,)):
  2. ... print(i,v)
  3. ...
  4.  
  5. >>>

应用举例:

  1. #代码
  2. product_list = [
  3. ['IPhone',],
  4. ['ofo',],
  5. ['MackBook',],
  6.  
  7. ]
  8.  
  9. for index,i in enumerate(product_list):
  10. print("%s,\t%s\t%s" %(index,i[],i[]))
  11.  
  12. #运行结果
  13. C:\Python35\python.exe D:/Python代码目录/day2/list.py
  14. , IPhone
  15. , ofo
  16. , MackBook
  17.  
  18. Process finished with exit code

字符串操作(str)

特性:不可修改

常用操作:

  1. >>> name = 'chunwei wu'
  2. >>> name.capitalize() #首字母大写
  3. 'Chunwei wu'
  4. >>>
  5.  
  6. >>> name = 'CHUNWEI WU'
  7. >>> name.casefold() #全部大写变小写
  8. 'chunwei wu'
  9. >>>
  10.  
  11. >>> name
  12. 'CHUNWEI WU'
  13. >>> name.center(20,"-") #输出20个字符,不足的以"-"补全
  14. '-----CHUNWEI WU-----'
  15. >>>
  16.  
  17. >>> name
  18. 'CHUNWEI WU'
  19. >>> name.count('U') #统计(默认是统计所有,可以指定统计范围)
  20. 2
  21. >>> name.count('U',0,10)
  22. 2
  23. >>> name.count('U',0,9)
  24. 1
  25. >>>
  26.  
  27. >>> name
  28. 'CHUNWEI WU'
  29. >>> name.endswith("Wu") #以什么结尾,匹配到则为真(返回True),匹配不到则为假(返回False)
  30. False
  31. >>> name.endswith("WU")
  32. True
  33. >>> name.endswith("CHUNWEI")
  34. False
  35. >>>
  36.  
  37. >>> "Chunwei\tWu".expandtabs(10) #将\t转换成多长的空格
  38. 'Chunwei Wu'
  39. >>> "Chunwei\tWu".expandtabs(15)
  40. 'Chunwei Wu'
  41.  
  42. >>> name
  43. 'CHUNWEI WU'
  44. >>> name.find('Wu') #查找Wu,找到返回其索引,找不到返回-1
  45. -1
  46. >>> name.find('CHUNWEI')
  47. 0
  48.  
  49. #format格式的三种赋值方式
  50. >>> msg = "my name is {},and age is {}"
  51. >>> msg.format("chunweiwu",23)
  52. 'my name is chunweiwu,and age is 23'
  53. >>>
  54. >>> msg = "my name is {0},and age is {1}"
  55. >>> msg.format("chunweiwu",23)
  56. 'my name is chunweiwu,and age is 23'
  57. >>>
  58. >>> msg = "my name is {name},and age is {age}"
  59. >>> msg.format(age=23,name="chunweiwu") #无需位置对齐
  60. 'my name is chunweiwu,and age is 23'
  61. >>>
  62.  
  63. #format_map格式赋值
  64. >> > msg = "my name is {name}, and age is {age}"
  65. >> > msg.format_map({'name': 'chunweiwu', 'age': 23})
  66. 'my name is chunweiwu, and age is 23'
  67.  
  68. >>> "abCDe".isalpha() #是不是字母,是则为True,不是则为False
  69. True
  70. >>> "123e".isalpha()
  71. False
  72. >>>
  73.  
  74. >>> "".isdigit() #是不是正整数,是返回True,否返回False
  75. True
  76. >>> "".isdigit()
  77. True
  78. >>> "-5".isdigit()
  79. False
  80. >>>
  81.  
  82. >>> "al_ex".isidentifier() #是不是一个合法的变量名,是返回True,否返回False
  83. True
  84. >>> "2x".isidentifier()
  85. False
  86. >>>
  87.  
  88. >>> "wei".islower() #是不是小写(全部)
  89. True
  90. >>> "weiG".islower()
  91. False
  92. >>>
  93.  
  94. >>> "3.1".isnumeric() #是不是数字(不带小数点),是为True,否为False
  95. False
  96. >>> "".isnumeric()
  97. True
  98. >>> "31.45".isnumeric()
  99. False
  100. >>>
  101.  
  102. >>> "weiG".isupper() #是不是大写(全部)
  103. False
  104. >>> "WeiG".isupper()
  105. False
  106. >>> "WG".isupper()
  107. True
  108. >>>
  109.  
  110. >>> print("My Name Is Wu".istitle()) #是不是首字母都是大写
  111. True
  112. >>> print("My Name Is su".istitle())
  113. False
  114. >>>
  115.  
  116. >>> ",".join("hello") #以指定的字符连接字符
  117. 'h,e,l,l,o'
  118. >>> "-".join("wuchunwei")
  119. 'w-u-c-h-u-n-w-e-i'
  120. >>> "|".join(["hello","good","hi"])
  121. 'hello|good|hi'
  122. >>>
  123.  
  124. >>> "chunwei".ljust(15,'-') #以-符号右填充共15个字符
  125. 'chunwei--------'
  126. >>>
  127.  
  128. >>> "chunwei".rjust(15,'-') #以-符号左填充共15个字符
  129. '--------chunwei'
  130. >>>
  131.  
  132. >>> "ChunWei".lower() #将大写变小写
  133. 'chunwei'
  134. >>> "CHUNWEI".lower()
  135. 'chunwei'
  136. >>>
  137.  
  138. >>> " wu \n".rstrip() #去右空格
  139. ' wu'
  140. >>> "\n wuchunwei \n".rstrip()
  141. '\n wuchunwei'
  142. >>>
  143.  
  144. >>> "\n wu \n".lstrip() #去左空格
  145. 'wu \n'
  146. >>> " \n wuchunwei ".lstrip()
  147. 'wuchunwei '
  148. >>>

 >>> name="wuchunwei"
 >>> name.rstrip('i')#右边指定字符串
 'wuchunwe'
 >>> name.rstrip('ei')
 'wuchunw'
 >>> name.rstrip('wi')
 'wuchunwe'
 >>> name.lstrip('w') #去左边指定字符串
 'uchunwei'
 >>> name.lstrip('wi')
 'uchunwei'
 >>> name.lstrip('u')
 'wuchunwei'
>>>

  1.  
  2. #等位替换(加密解密)
  3. >>> from_str = "!@#$%^&"
  4. >>> to_str = "abcdefg"
  5. >>> trans_table = str.maketrans(to_str,from_str)
  6. >>> print("backup".translate(trans_table))
  7. @!#kup
  8. >>>
  9.  
  10. >>> "hello world 666 good".partition("w") #以指定字符分割成3份(指定的字符不存在以空分割)
  11. ('hello ', 'w', 'orld 666 good')
  12. >>> "hello world 666 good".partition("")
  13. ('hello world ', '', ' good')
  14. >>> "hello world 666 good".partition("z")
  15. ('hello world 666 good', '', '')
  16. >>>
  17.  
  18. >>> "hello".replace("l","L") #以特定字符替换现有字符,可以设定替换次数(默认替换全部)
  19. 'heLLo'
  20. >>> "hello".replace("h","HHH")
  21. 'HHHello'
  22. >>> "hello".replace("l","L",1)
  23. 'heLlo'
  24. >>>
  25.  
  26. >>> "wu\n chun\nwei".splitlines() #以\n分隔
  27. ['wu', ' chun', 'wei']
  28. >>> "\nwuchun\nwei".splitlines()
  29. ['', 'wuchun', 'wei']
  30.  
  31. >>> "\nwuchun\nwei".split("u") #以指定的字符分割(保留特殊字符)
  32. ['\nw', 'ch', 'n\nwei']
  33. >>>
  1. #计数器
    import collections
    obj = collections.Counter('zzzfcsdvc,dasdwezzrggfdgeqwewewe')
    print(obj)
    """ 结果: C:\Python35\python.exe D:/Python代码目录/Python_codeing/caixing_codeing/day3/有序字典.py
    Counter({'z': 5, 'e': 5, 'w': 4, 'd': 4, 'g': 3, 'f': 2, 's': 2, 'c': 2, 'r': 1, ',': 1, 'q': 1, 'v': 1, 'a': 1}) """

字典(dict)

字典是一种key-value的数据类型,使用就像上学时用的字典,可以通过笔划、字母来查对应页的详细内容

语法:

  1. info = {
  2. 'stu1101': "Chunwei Wu",
  3. 'stu1102': "Mengmeng Yang",
  4. 'stu1103': "Qi Wei",
  5. }

字典的特性:

  1. 1dict是无序的
  2. 2key必须是唯一的,so 天生去重

快速定义一个字典(fromkeys)

  1. ###实例代码:
  2. dic1=dict.fromkeys('abc',) #分别以a、b、c为key,1为value为键值创建字典(去重)
  3. print("dict1===>",dic1)
  4. dic2=dic1.fromkeys('hello',)
  5. print("dict2===>",dic2)
  6. dic3=dict.fromkeys([,,],{'names':'weige','age':})
  7. print("dict3===>",dic3)
  8.  
  9. ###运行结果:
  10. C:\Python35\python.exe D:/Python代码目录/day3/字典.py
  11. dict1===> {'a': , 'b': , 'c': }
  12. dict2===> {'l': , 'o': , 'e': , 'h': }
  13. dict3===> {: {'age': , 'names': 'weige'}, : {'age': , 'names': 'weige'}, : {'age': , 'names': 'weige'}}
  14.  
  15. Process finished with exit code

字典的常见操作:

  1. ===》增加
  2. >>> info
  3. {'stu1101': 'Chunwei Wu', 'stu1103': 'Qi Wei', 'stu1102': 'Mengmeng Yang'}
  4. >>> info["stu1104"] = "吴春伟" #增加一个字典数值
  5. >>> info
  6. {'stu1101': 'Chunwei Wu', 'stu1103': 'Qi Wei', 'stu1104': '吴春伟', 'stu1102': 'Mengmeng Yang'} #字典是无序的
  7. >>>
  8.  
  9. ===》修改
  10. >>> info
  11. {'stu1101': 'Chunwei Wu', 'stu1103': 'Qi Wei', 'stu1104': '吴春伟', 'stu1102': 'Mengmeng Yang'}
  12. >>> info['stu1104'] = "WUCHUNWEI" #修改(重新赋值)
  13. >>> info
  14. {'stu1101': 'Chunwei Wu', 'stu1103': 'Qi Wei', 'stu1104': 'WUCHUNWEI', 'stu1102': 'Mengmeng Yang'}
  15. >>>
  16.  
  17. ===》删除
  18. >>> info
  19. {'stu1101': 'Chunwei Wu', 'stu1103': 'Qi Wei', 'stu1104': 'WUCHUNWEI', 'stu1102': 'Mengmeng Yang'}
  20. >>> info.pop("stu1104") #标准删除姿势(需要指定key键值)
  21. 'WUCHUNWEI'
  22. >>> info
  23. {'stu1101': 'Chunwei Wu', 'stu1103': 'Qi Wei', 'stu1102': 'Mengmeng Yang'}
  24. >>>
  25. >>> del info['stu1101'] #字典删除方式2
  26. >>> info
  27. {'stu1103': 'Qi Wei', 'stu1102': 'Mengmeng Yang'}
  28. >>>
  29. >>> info
  30. {'stu1101': 'Nginx', 'stu1103': 'Qi Wei', 'stu1105': 'PHP', 'stu1104': 'Apache', 'stu1102': 'Mengmeng Yang'}
  31. >>> info.popitem() #popitem随机删除
  32. ('stu1101', 'Nginx')
  33. >>> info
  34. {'stu1103': 'Qi Wei', 'stu1105': 'PHP', 'stu1104': 'Apache', 'stu1102': 'Mengmeng Yang'}
  35. >>> info.popitem()
  36. ('stu1103', 'Qi Wei')
  37. >>> info
  38. {'stu1105': 'PHP', 'stu1104': 'Apache', 'stu1102': 'Mengmeng Yang'}
  39. >>> info.popitem()
  40. ('stu1105', 'PHP')
  41. >>> info
  42. {'stu1104': 'Apache', 'stu1102': 'Mengmeng Yang'}
  43. >>>
  44.  
  45. ===》查找
  46. >>> info
  47. {'stu1104': 'Apache', 'stu1102': 'Mengmeng Yang'}
  48. >>> "stu1102" in info #标准用法
  49. True
  50. >>> info.get("stu1102") #获取(查找)
  51. 'Mengmeng Yang'
  52. >>> info["stu1102"] #第二种方法
  53. 'Mengmeng Yang'
  54. >>>
  55. >>> info.get("stu1108") #当查找一个不存在的字典key时:get方式为空不报错;第二种方式会报错
  56. >>> info["stu1108"]
  57. Traceback (most recent call last):
  58. File "<stdin>", line 1, in <module>
  59. KeyError: 'stu1108'
  60. >>>
  61.  
  62. ===》更新
  63. >>> info
  64. {'stu1101': 'WeiGe', 'stu1102': 'Mengmeng Yang'}
  65. >>> user = {1:'a',2:'b',"stu103":"吴春伟"}
  66. >>> info.update(user)
  67. >>> info
  68. {'stu1101': 'WeiGe', 2: 'b', 1: 'a', 'stu103': '吴春伟', 'stu1102': 'Mengmeng Yang'}
  69. >>>
  70.  
  71. ===》其他用法操作
  72. >>> info
  73. {'stu1104': 'Apache', 'stu1102': 'Mengmeng Yang'}
  74. >>> info.values() #获取字典的value值
  75. dict_values(['Apache', 'Mengmeng Yang'])
  76. >>>
  77. >>> info.keys() #获取字典的key值
  78. dict_keys(['stu1104', 'stu1102'])
  79. >>>
  80.  
  81. >>> info
  82. {'stu1104': 'Apache', 'stu1102': 'Mengmeng Yang'}
  83. >>> info.setdefault("stu1102","WeiGe") #当原key存在不做改变(当key不存在时,新增一对key:value)
  84. 'Mengmeng Yang'
  85. >>> info
  86. {'stu1104': 'Apache', 'stu1102': 'Mengmeng Yang'}
  87. >>> info.setdefault("stu1101","WeiGe") #当key不存在时,新增一对key:value(当原key存在不修改)
  88. 'WeiGe'
  89. >>> info
  90. {'stu1101': 'WeiGe', 'stu1104': 'Apache', 'stu1102': 'Mengmeng Yang'}
  91. >>>
  92.  
  93. >>> info
  94. {'stu1101': 'WeiGe', 2: 'b', 1: 'a', 'stu103': '吴春伟', 'stu1102': 'Mengmeng Yang'}
  95. >>> info.items() #转换为列表
  96. dict_items([('stu1101', 'WeiGe'), (2, 'b'), (1, 'a'), ('stu103', '吴春伟'), ('stu1102', 'Mengmeng Yang')])
  97. >>>

两种取字典里的ke、value值得方式  (循环dict)

  1. ===》实例
  2. user = {
  3. "stu1101":"chunweiwu",
  4. "stu1102": "Mengmeng Yang",
  5. "stu1103": "Qi Wei",
  6. "stu1104": "Helen",
  7. }
  8.  
  9. print("###方法1###")
  10. for key in user:
  11. print(key,user[key])
  12. print("###方法2(会先把dict转为list,大数据量是不推荐使用)###")
  13. for k,v in user.items():
  14. print(k,v)
  15.  
  16. ===》结果
  17. C:\Python35\python.exe "D:/Python代码目录/day 1/dict.py"
  18. ###方法1###
  19. stu1104 Helen
  20. stu1102 Mengmeng Yang
  21. stu1103 Qi Wei
  22. stu1101 chunweiwu
  23. ###方法2(会先把dict转为list,大数据量是不推荐使用)###
  24. stu1104 Helen
  25. stu1102 Mengmeng Yang
  26. stu1103 Qi Wei
  27. stu1101 chunweiwu
  28.  
  29. Process finished with exit code 0

深浅拷贝(copy|deepcopy)

  1. import copy
  2. ###浅拷贝
  3. copy.copy()
  4. ###深copy
  5. copy.deepcopy()
  6.  
  7. 实例:
  8. dic1={'name':'weige','age':,'gfs':["MwngQi","Roses","Helly"]}
  9. dic2=dic1
  10. dic3=copy.copy(dic1) #字典里的浅copy就是copy模块里的copy
  11. print(dic1)
  12. print(dic2)
  13. print(dic3)
  14. 结果:
  15. C:\Python35\python.exe D:/Python代码目录/day3/字典.py
  16. {'gfs': ['MwngQi', 'Roses', 'Helly'], 'name': 'weige', 'age': }
  17. {'gfs': ['MwngQi', 'Roses', 'Helly'], 'name': 'weige', 'age': }
  18. {'gfs': ['MwngQi', 'Roses', 'Helly'], 'name': 'weige', 'age': }
  19.  
  20. Process finished with exit code
  1. ###代码###
  2. info ={
  3. 'cpu':[80,],
  4. 'disk':[90,],
  5. 'mem':[85,]
  6. }
  7. print("befo===> ",info)
  8.  
  9. print("======copy======")
  10. info_c=copy.copy(info)
  11. info_c['mem'][0]=100
  12. print("befo===> ",info)
  13. print("copy===> ",info_c)
  14.  
  15. print("======deepcopy======")
  16. info_dc=copy.deepcopy(info)
  17. info_dc['cpu'][0]=50
  18. print("befo===> ",info)
  19. print("deepcopy===> ",info_dc)
  20.  
  21. ###结果###
  22. C:\Python35\python.exe D:/Python代码目录/day3/字典.py
  23. befo===> {'mem': [85], 'cpu': [80], 'disk': [90]}
  24. ======copy======
  25. befo===> {'mem': [100], 'cpu': [80], 'disk': [90]}
  26. copy===> {'mem': [100], 'cpu': [80], 'disk': [90]}
  27. ======deepcopy======
  28. befo===> {'mem': [100], 'cpu': [80], 'disk': [90]}
  29. deepcopy===> {'mem': [100], 'cpu': [50], 'disk': [90]}
  30.  
  31. Process finished with exit code 0

硬件参数copy与deepcopy事例

集合(set)

  集合是一个无序的、不重复的数据组合,主要作用如下:

  1)去重:把一个列表变成集合,就自动去重了

  2)关系测试:测试两组数据之前的交集、差集、并集等测试

集合的常见内置方法

  1. ###交集:取共有部分
  2. stu_1={'hello','weige','monkey','kitty'}
  3. stu_2={'weige','mengqi','tiger'}
  4. print(stu_1&stu_2)
  5. print(stu_1.intersection(stu_2))
  6.  
  7. C:\Python35\python.exe D:/Python代码目录/day3/集合.py
  8. {'weige'}
  9. {'weige'}
  10.  
  11. Process finished with exit code
  12.  
  13. ###并集:取包含两个集合所有的元素
  14. num_1={,,,,}
  15. num_2={,}
  16. ##并集:取包含所有的
  17. print(num_1|num_2)
  18. print(num_1.union(num_2))
  19.  
  20. C:\Python35\python.exe D:/Python代码目录/day3/集合.py
  21. {, , , , }
  22. {, , , , }
  23.  
  24. Process finished with exit code
  25.  
  26. ###差集:用集合1中减去集合2中有的,剩余的就为集合1与集合2的差集
  27. num_1={,,,,}
  28. num_2={,}
  29. print(num_1-num_2)
  30. print(num_1.difference(num_2))
  31. print(num_2-num_1) #没有这为空
  32.  
  33. C:\Python35\python.exe D:/Python代码目录/day3/集合.py
  34. {, , }
  35. {, , }
  36. set()
  37.  
  38. Process finished with exit code
  39.  
  40. ###对称差集:集合1与集合2所有的减去两者共有的剩下所有
  41. num_1={,,,,}
  42. num_2={,}
  43. print(num_1^num_2)
  44. print(num_1.symmetric_difference(num_2))
  45.  
  46. C:\Python35\python.exe D:/Python代码目录/day3/集合.py
  47. {, , }
  48. {, , }
  49.  
  50. Process finished with exit code
  51.  
  52. ###子集:小于等于,返回布尔值;True和False
  53. num_1={,,,,}
  54. num_2={,}
  55. print(num_1<=num_2)
  56. print(num_1.issubset(num_2))
  57. print(num_2.issubset(num_1))
  58.  
  59. C:\Python35\python.exe D:/Python代码目录/day3/集合.py
  60. False
  61. False
  62. True
  63.  
  64. Process finished with exit code
  65.  
  66. ###父集:大于等于
  67. num_1={,,,,}
  68. num_2={,}
  69. print(num_1>=num_2)
  70. print(num_1.issuperset(num_2))
  71. print(num_2.issuperset(num_1))
  72.  
  73. C:\Python35\python.exe D:/Python代码目录/day3/集合.py
  74. True
  75. True
  76. False
  77.  
  78. Process finished with exit code

集合其他内置方法

  1. ###更新update
  2. s1={1,2,3}
  3.  
  4. s1.update('e')
  5. s1.update((1,2,3,4))
  6. s2={'h','e','l'}
  7. s1.update('hello')
  8. print(s1)
  9.  
  10. C:\Python35\python.exe D:/Python代码目录/day3/集合.py
  11. {'h', 1, 2, 3, 4, 'o', 'l', 'e'}
  12.  
  13. Process finished with exit code 0
  14.  
  15. ###增加add
  16. s1={1,2,3}
  17. s1.add('hello')
  18. print(s1)
  19.  
  20. C:\Python35\python.exe D:/Python代码目录/day3/集合.py
  21. {1, 2, 3, 'hello'}
  22.  
  23. Process finished with exit code 0
  24.  
  25. ###随机删除pop
  26. s1={1,2,3}
  27. s1.pop()
  28. print(s1)
  29.  
  30. C:\Python35\python.exe D:/Python代码目录/day3/集合.py
  31. {2, 3}
  32.  
  33. Process finished with exit code 0
  34.  
  35. ###指定删除(元素不存在则报错)
  36. s1={1,2,3}
  37. s1.remove('w')
  38.  
  39. C:\Python35\python.exe D:/Python代码目录/day3/集合.py
  40. Traceback (most recent call last):
  41. File "D:/Python代码目录/day3/集合.py", line 88, in <module>
  42. s1.remove('w')
  43. KeyError: 'w'
  44.  
  45. Process finished with exit code 1
  46.  
  47. ###删除元素不存在的集合不报错的删除方式
  48. s1={1,2,3}
  49. print(s1.discard('a'))
  50.  
  51. C:\Python35\python.exe D:/Python代码目录/day3/集合.py
  52. None
  53.  
  54. Process finished with exit code 0
  55.  
  56. ###差集更新(s1=s1-s2)
  57. s1={1,2,5,'a','c'}
  58. s2={1,2}
  59. s1.difference_update(s2)
  60. print(s1)
  61.  
  62. C:\Python35\python.exe D:/Python代码目录/day3/集合.py
  63. {5, 'a', 'c'}
  64.  
  65. Process finished with exit code 0

Python之旅Day2 元组 字符串 字典 集合的更多相关文章

  1. Python中列表,元组,字典,集合的区别

    参考文档https://blog.csdn.net/Yeoman92/article/details/56289287 理解Python中列表,元组,字典,集合的区别 列表,元组,字典,集合的区别是p ...

  2. Python基础-列表、元组、字典、字符串

    Python基础-列表.元组.字典.字符串   多维数组 nums1 = [1,2,3] #一维数组 nums2 = [1,2,3,[4,56]] #二维数组 nums3 = [1,2,3,4,['a ...

  3. python学习笔记(一)元组,序列,字典

    python学习笔记(一)元组,序列,字典

  4. Python中列表、元组、字典、集合与字符串,相关函数,持续更新中……

    本篇博客为博主第一次学 Python 所做的笔记(希望读者能够少点浮躁,认真阅读,平心静气学习!) 补充: 列表.元组和字符串共同属性: 属于有序序列,其中的元素有严格的先后顺序 都支持双向索引,索引 ...

  5. Python 全栈开发二 python基础 字符串 字典 集合

    一.字符串 1,在python中,字符串是最为常见的数据类型,一般情况下用引号来创建字符串. >>ch = "wallace" >>ch1 = 'walla ...

  6. python基础语法3 元组,字典,集合

    元组: ========================元组基本方法===========================用途:存储多个不同类型的值定义方式:用过小括号存储数据,数据与数据之间通过逗号 ...

  7. python数据类型详解及列表字典集合推导式详解

    一.运算符 Python语言支持以下类型的运算符: 算术运算符 如: #!/usr/bin/env python # -*- coding:utf-8 -*- a = 5 b = 6 print(a ...

  8. Day 15 python 之 列表、元组、字典

    基础: #! /usr/bin/env python # -*- coding: utf-8 -*- # __author__ = "DaChao" # Date: 2017/6/ ...

  9. Python学习---列表,元组,字典

    ### 列表 list = [1,2,3,4,5,6] list.append(7) print(list) ===>>> [1, 2, 3, 4, 5, 6, 7] list[2] ...

随机推荐

  1. MYSQL5.7实时同步数据到TiDB

    操作系统:CentOS7 mysql版本:5.7 TiDB版本:2.0.0 同步方法:使用TiDB提供的工具集进行同步 说明: 单机mysql同步时,可以直接使用binlog同步, 但mysql集群进 ...

  2. nginx+python+windows 开始

    参考文章:http://www.testwo.com/article/311 参考如上文章基本能够完成hello world示例,我来记录下自己操作步骤及不同点,用以备忘,如果能帮助到其他人更好. 以 ...

  3. leetcode347

    public class Solution { public IList<int> TopKFrequent(int[] nums, int k) { var dic = new Dict ...

  4. 利用nginx添加账号密码验证

    server { listen ; server_name xxx.com; location / { proxy_pass http://10.10.10.10:5601; proxy_redire ...

  5. YAML基本语法

    正如YAML所表示的YAML Ain’t Markup Language,YAML /ˈjæməl/ 是一种简洁的非标记语言.YAML以数据为中心,使用空白,缩进,分行组织数据,从而使得表示更加简洁易 ...

  6. HTTP 中 GET 与 POST 的区别

    最直观的区别就是GET把参数包含在URL中,POST通过request body传递参数. GET和POST是什么?HTTP协议中的两种发送请求的方法. HTTP是什么?HTTP是基于TCP/IP的关 ...

  7. 私活利器,docker快速部署node.js应用

    http://cnodejs.org/topic/53f494d9bbdaa79d519c9a4a 最近研究了几天docker的快速部署,感觉很有新意,非常轻量级和方便,打算在公司推广一下,解放运维, ...

  8. # 20175213 2018-2019-2 《Java程序设计》第1周学习总结

    在本周的java学习中,我收获了很多也遇到了很多的困难1.在寒假的预学习中,因为没能完全的安好虚拟机,导致在本周的学习一开始,虚拟机就崩溃了,所以又重新开始重头安装虚拟机.但因为网速等各种问题,虚拟机 ...

  9. linux 下将tomcat注册成服务并开机启动

    一.将startup.sh和shutdown.sh新建软连接到/usr/bin ln -s /usr/local/apache-tomcat-8.5.38/bin/startup.sh /usr/bi ...

  10. cdnbest如何让用户访问走最近最快的线路(分组线路)

    用户访问网站有时网络有互通的问题,cdnbest的分组解析可以细分线路,让用户访问自动走最优线路,线路不细分都加默认里,访问的节点是随机分配的 下面我们讲下如何设置: 比如你有电信,移动,和国外的节点 ...