Thonny version 4.1.6

®Geovin Du Dream Park™ / 2024-09-22 / 原文

 

https://thonny.org/

https://github.com/thonny/thonny/releases

 

 

安装包的两种方式:

第一钟

 第二种:

 

 

pip国内源推荐

url
清华 https://pypi.tuna.tsinghua.edu.cn/simple/
阿里 http://mirrors.aliyun.com/pypi/simple/
网易 https://mirrors.163.com/pypi/simple/
百度 https://mirror.baidu.com/pypi/simple/
中科大 https://pypi.mirrors.ustc.edu.cn/simple/
腾讯 https://mirrors.cloud.tencent.com/pypi/simple/

 

 

import sys
import io
import os
import pandas # pip3.10 install pandas -i https://pypi.tuna.tsinghua.edu.cn/simple/

class Pepole(object):
    """
    人
    """
    def __init__(self):
        """
 
        :param name:
        :param age:
        """
        self._name='' #公有属性
        self.__age=0 #私用属性,需要通过(函数)setter,getter 设置和访问
        
        
    @property  # @property装饰getter方法  get ,set 名字相符
    def Age(self):
        """
 
        :return:
        """
        return self.__age
 
    @Age.setter
    def Age(self,age):  #@方法名.setter 设置
        """
 
        :param age:
        :return:
        """
        if age>0:
            self.__age=age
            
    @property
    def Name(self):
        """
        """
        return self._name
    
    @Name.setter
    def Name(self,name):
        """
        """
        self._name=name
    
    
    

def load_record():
    """
    read data 
    """
    f=open("data/phonebook.txt","r")
    global record #set global variable
    record=f.readlines()
    for i in range(0,len(record)):
        record[i]=record[i].replace("\n","")
        record[i]=record[i].split(",")
    f.close()
    

def print_record():
    """
    print list
    """
    for i in range(0,len(record)):
       for j in range(0,4):
          print(record[i][j],end="\t")        
       print("")
   
   
def search_recordByFirstname(firstname):    
    """
    search firestname
    """
    for i in range(0,len(record)):
        for i in range(0,len(record)):
            #print(record[i][1])
            if record[i][1]==firstname:                
                return i
        return -1
    
    
    
    
if __name__=="__main__":
    """
    main export 
    """
    print("hello");
    
    p=Pepole()
    p.Name='geovindu'
    p.Age=20
    print(p.Name,p.Age)
	
    
    load_record()
    print_record()
    pos=search_recordByFirstname("Rose")
    print('search:')
    print(pos,record[pos][1]+' '+record[pos][2])
    
    filename='1.txt'
    if os.path.exists("data/"+filename):        
        with open("data/"+filename,"r",encoding="utf8") as f:
            txt=f.read()
            print(txt)
        f.close()