這是最後一條NLP了......來吧 十二,動機和情緒總不會錯,只是行為沒有效果而已 動機在潛意識裡,總是正面的。潛意識從來不會傷害自己,只會誤會的以為某行為可以滿足該動機,而又不知道有其他做法的可能。 情緒總是給我們一份推動力,情緒使我們在該事情之中有所學習,學到了,情緒便會消失。 我們可以接受一 ...
這是最後一條NLP了......來吧
十二,動機和情緒總不會錯,只是行為沒有效果而已
動機在潛意識裡,總是正面的。潛意識從來不會傷害自己,只會誤會的以為某行為可以滿足該動機,而又不知道有其他做法的可能。
情緒總是給我們一份推動力,情緒使我們在該事情之中有所學習,學到了,情緒便會消失。
我們可以接受一個人的動機和情緒,同時不接受他的行為。
接受動機和情緒,便是接受那個人,那個人也會感覺出你對他的接受,因而更肯讓你去引導他做出改變。
任何一次行為不等於一個人。
行為不能接受,是因為沒有效果,找出更好的做法,是兩個人共同的目標,能使兩個人有跟好的溝通和關係。
找出更好的做法的方法之一是追查動機背後的價值觀。
員工信息表
題目:
接下來是代碼了,哇果然是敲著敲著就發現好多以前從來沒註意的東西,好多細節。
staff_list文件如下:
1,alex,22,13651054608,IT
2,egon,23,133043202533,teacher
3,nezha,25,1333235322,IT
代碼:
1 #!usr/bin/env/ python 2 # -*- coding:utf-8 -*- 3 # Author: XiaoFeng 4 import os 5 li = ["id", "name", "age", "phone", "job"] 6 flag = False 7 staff_id = None 8 number = "xiaofeng" 9 word = "123456" 10 11 12 def login(func): 13 def inner(): 14 global flag 15 if not flag: 16 print("如想操作員工信息,請先等錄:") 17 account = input("請輸入您的賬號:").strip() 18 password = input("請輸入您的密碼:").strip() 19 if account == number and password == word: 20 flag = True 21 print("登陸成功!") 22 res = func() 23 return res 24 else: 25 print("賬號或密碼錯誤,登陸失敗!") 26 else: 27 res = func() 28 return res 29 return inner 30 31 32 def handle(content_1): 33 if "select" or "set" in content_1 and "where" in content_1: 34 info_start = content_1.index("t") + 1 35 info_end = content_1.index("where") - 1 36 info = content_1[info_start:info_end].strip() 37 condition = content_1[info_end + 6:].strip() 38 return info, condition 39 else: 40 print("輸入錯誤!") 41 42 43 def seek(): 44 content = input("請輸入操作:(如select name, age where age>22)").strip().lower() 45 if content.startswith("select") and "where" in content: 46 handle_str_1 = handle(content) 47 out_list = [] 48 for p in li: 49 if p in handle_str_1[1]: 50 if ">" in handle_str_1[1]: 51 info_list = handle_str_1[0].split(",") 52 str_info = " ".join(info_list) 53 info_list = str_info.split() # 去字元串內空格 54 index_0 = handle_str_1[1].index(">") 55 character = handle_str_1[1][:index_0].strip() 56 num = handle_str_1[1][index_0 + 1:].strip() 57 if num.isdigit(): 58 num = int(num) 59 with open("staff_list", "r", encoding="utf-8") as f: 60 for line in f: 61 if not line.isspace(): 62 line_list = line.strip().split(",") 63 character_value = int(line_list[li.index(character)]) 64 if character_value > num: 65 if handle_str_1[0].strip() == "*": 66 out = " ".join(line_list) 67 print(out) 68 out_list.clear() 69 else: 70 for n in info_list: 71 out_list.append(line_list[li.index(n)]) 72 out = " ".join(out_list) 73 print(out) 74 out_list.clear() 75 else: 76 print("請輸入數字!") 77 elif "<" in handle_str_1[1]: 78 info_list = handle_str_1[0].split(",") 79 str_info = " ".join(info_list) 80 info_list = str_info.split() 81 index_1 = handle_str_1[1].index("<") 82 character = handle_str_1[1][:index_1].strip() 83 num = handle_str_1[1][index_1 + 1:].strip() 84 if num.isdigit(): 85 num = int(num) 86 with open("staff_list", "r", encoding="utf-8") as f: 87 for line in f: 88 if not line.isspace(): 89 line_list = line.strip().split(",") 90 character_value = int(line_list[li.index(character)]) 91 if character_value < num: 92 if handle_str_1[0].strip() == "*": 93 out = " ".join(line_list) 94 print(out) 95 out_list.clear() 96 else: 97 for n in info_list: 98 out_list.append(line_list[li.index(n)]) 99 out = " ".join(out_list) 100 print(out) 101 out_list.clear() 102 else: 103 print("請輸入數字!") 104 elif "=" in handle_str_1[1]: 105 info_list = handle_str_1[0].split(",") 106 str_info = " ".join(info_list) 107 info_list = str_info.split() 108 index_2 = handle_str_1[1].index("=") 109 character = handle_str_1[1][:index_2].strip() 110 num = handle_str_1[1][index_2 + 1:].strip() 111 if num.isdigit(): 112 num = int(num) 113 with open("staff_list", "r", encoding="utf-8") as f: 114 for line in f: 115 if not line.isspace(): 116 line_list = line.strip().split(",") 117 character_value = int(line_list[li.index(character)]) 118 if num == character_value: 119 if handle_str_1[0].strip() == "*": 120 out = " ".join(line_list) 121 print(out) 122 out_list.clear() 123 else: 124 for n in info_list: 125 out_list.append(line_list[li.index(n)]) 126 out = " ".join(out_list) 127 print(out) 128 out_list.clear() 129 else: 130 with open("staff_list", "r", encoding="utf-8") as f: 131 for line in f: 132 if not line.isspace(): 133 line_list = line.strip().split(",") 134 character_value = line_list[li.index(character)] 135 if num == character_value: 136 if handle_str_1[0].strip() == "*": 137 out = " ".join(line_list) 138 print(out) 139 out_list.clear() 140 else: 141 for n in info_list: 142 out_list.append(line_list[li.index(n)]) 143 out = " ".join(out_list) 144 print(out) 145 out_list.clear() 146 elif "like" in handle_str_1[1]: 147 info_list = handle_str_1[0].split(",") 148 str_info = " ".join(info_list) 149 info_list = str_info.split() 150 index_3 = handle_str_1[1].index("like") 151 character = handle_str_1[1][:index_3].strip() 152 num = handle_str_1[1][index_3 + 4:].strip() 153 with open("staff_list", "r", encoding="utf-8") as f: 154 for line in f: 155 if not line.isspace(): 156 line_list = line.strip().split(",") 157 character_value = line_list[li.index(character)] 158 if num in character_value: 159 if handle_str_1[0].strip() == "*": 160 out = " ".join(line_list) 161 print(out) 162 out_list.clear() 163 else: 164 for n in info_list: 165 out_list.append(line_list[li.index(n)]) 166 out = " ".join(out_list) 167 print(out) 168 out_list.clear() 169 else: 170 print("\033[31;1m您輸入的條件不符合規範!\033[0m") 171 else: 172 print("請輸入正確的操作語句!") 173 174 175 @login 176 def add(): 177 global staff_id 178 if not staff_id: 179 if os.path.getsize("staff_list") == 0: 180 staff_id = 0 181 else: 182 d = 0 183 with open("staff_list", "r", encoding="utf-8") as f: 184 for line in f: 185 if not line.isspace(): 186 line_list = line.strip().split(",") 187 print(line_list) 188 if line_list[0]: 189 d = line_list[0] 190 print(d) 191 staff_id = int(d) 192 print("\033[41;1m請按提示輸入信息\033[0m".center(39, "*")) 193 new_staff = [] 194 for a in li[1:]: 195 staff_info = input("請輸入新員工的%s:" % a).strip() 196 new_staff.append(staff_info) 197 new_staff_str = ",".join(new_staff) 198 staff_id += 1 199 id_str = str(staff_id) 200 final_str = id_str + "," + new_staff_str + "\n" 201 with open("staff_list", "a", encoding="utf-8") as f: 202 f.write(final_str) 203 print("您添加的信息為:{}".format(final_str)) 204 205 206 @login 207 def delete(): 208 id_delete = input("請輸入要刪除員工的id號:") 209 with open("staff_list", "r", encoding="utf-8") as f1, \ 210 open("staff_list_bak", "w", encoding="utf-8") as f2: 211 for line in f1: 212 if not line.isspace(): 213 line_list = line.strip().split(",") 214 if id_delete == line_list[0]: 215 continue 216 f2.write(line) 217 os.remove("staff_list") 218 os.rename("staff_list_bak", "staff_list") 219 print("刪除成功!") 220 221 222 @login 223 def modify(): 224 content = input("請輸入要修改的內容(如set 列名=“新的值” where id=x)").strip() 225 handle_str = handle(content) 226 info_list = handle_str[0].split(",") 227 str_info = " ".join(info_list) 228 info_list = str_info.split() # 去字元串內空格 229 index_2 = handle_str[1].index("=") 230 character = handle_str[1][:index_2].strip() 231 num = handle_str[1][index_2 + 1:].strip() 232 if num.isdigit(): 233 num_int = int(num) 234 with open("staff_list", "r", encoding="utf-8") as f1, \ 235 open("staff_list_bak", "w", encoding="utf-8") as f2: 236 for line in f1: 237 if not line.isspace(): 238 line_list = line.strip().split(",") 239 character_value = int(line_list[li.index(character)]) 240 if num_int == character_value: 241 for c in info_list: 242 index_1 = c.index("=") 243 set_key = c[:index_1].strip() 244 set_value = c[index_1 + 1:].strip() 245 line_list[li.index(set_key)] = set_value 246 line = ",".join(line_list) 247 f2.write(line) 248 os.remove("staff_list") 249 os.rename("staff_list_bak", "staff_list") 250 else: 251 print("請輸入正確語句!") 252 253 254 operate_list = ["查找", "新增", "刪除", "修改"] 255 while True: 256 print("-" * 50) 257 for index, i in enumerate(operate_list): 258 print(index, "\t", i) 259 choice = input("請輸入您個的選擇編號:").strip() 260 if choice.isdigit() and choice == "0": 261 seek() 262 elif choice.isdigit() and choice == "1": 263 add() 264 elif choice.isdigit() and choice == "2": 265 delete() 266 elif choice.isdigit() and choice == "3": 267 modify() 268 else: 269 print("請按要求輸入編號")