#%% Change working directory from the workspace root to the ipynb file location. Turn this addition off with the DataScience.changeDirOnImportExport setting import os try: os.chdir(os.path.join(os.getcwd(), 'learning_note\python_code')) print(os.getcwd()) except: pass #%% '''计ç®ä¸æ®µå符串é¿åº¦''' s1 = "hello world" length = 0 for i in s1: length = length+1 #æ¯æ¬¡å¾ªç¯å¢å ä¸ä¸ªæ°''' print(length) #æå°åºå符串é¿åº¦æ°å¼''' #%% s2 = "hell eva" length = 0 for i in s2: length = length+1 print(length) #%% print(len(s1)) print(len(s2)) #%% def mylen(): s1 = "hello world" """计ç®s1çé¿åº¦""" length = 0 for i in s1: length = length+1 return length #%% str_len = mylen() print('str_len : %s'%str_len) #%% def mylen(s1): """计ç®s1çé¿åº¦""" length = 0 for i in s1: length = length+1 return length str_len = mylen("ä½ å¥½ä¸çï¼ææ¯æ°æï¼") print('str_len : %s'%str_len)