python学习
python自学笔记代码+说明
IT小白田田
我要好好学习
展开
-
numpy库知识
#numpy学习笔记import numpy as npfrom numpy.core.fromnumeric import ravel, argsort, argmax, argmin########################################一、numpy数组创建#####################################x=np.array([1,2,3,4,5])print( x )#设置数组的类型x=np.array([1,2,3,4,5].原创 2020-10-17 00:23:39 · 152 阅读 · 0 评论 -
8.2小游戏开发
from tkinter import *import tkinter.simpledialog as dlimport tkinter.messagebox as mb#主函数框root=Tk()#标签w=Label(root,text="Guess Number Game")#自适应w.pack()mb.showinfo("wellcome", "wellcome to Guess Number Game")number=59while True: guess ...原创 2020-09-17 12:18:32 · 81 阅读 · 0 评论 -
8.1图形界面gui
from tkinter import *import tkinter.simpledialog as dlimport tkinter.messagebox as mb#主函数框root=Tk()#标签w=Label(root,text="Label Tittle")#自适应w.pack()mb.showerror("wellcome", "wellcome message")#用户输入一个数字,赋给guessguess =dl.askfloat("number", "enter.原创 2020-09-17 12:17:40 · 98 阅读 · 0 评论 -
7.1面向对象编程
#类:显示事务的封装(学生)#类---》有属性(名字,成绩)#类对象#实例对象#引用#实例化:比如学生张三# class Student:# def __init__(self,name,grade):# self.name=name# self.grade=grade# def introduce(self):# print("hi i am"+self.name)# print("my grade ...原创 2020-09-17 12:17:10 · 515 阅读 · 0 评论 -
6.1错误与异常处理
#语法错误#while True print("hello world")# while True:# print("hello world")#异常#print(0/0)#print(hello*4)## num=6# print("hello world"+str(num))# #如果没有加上str也会出现异常#==============================================================================...原创 2020-09-17 12:15:14 · 98 阅读 · 0 评论 -
5.2输入输出文件中
# 写入文件操作:some_sentences='''\i love learning pythoni love you'''f=open('sentences.txt','w')f.write(some_sentences)f.close()#读文件f=open('sentences.txt')#不说明则默认是读文件操作while True: line=f.readline() if len(line)==0: break print(line...原创 2020-09-17 12:14:43 · 104 阅读 · 0 评论 -
5.1输入输出方式介绍
str_1=input("enter a string:")str_2=input("enter another string:")print("str_1:"+str_1+"str_2:"+str_2)print("str_1 is {}+str_2 is {}".format(str_1, str_2))原创 2020-09-17 12:14:11 · 284 阅读 · 0 评论 -
4.3 continue和pass和break
# # number=59# while True:# guess=int(input("enter an inteher:"))# if guess ==number:# break# #跳出该处所有循环# elif guess <number:# print("lower")# continue# #跳出当前循环# else:# print("highter")# ...原创 2020-09-17 12:13:32 · 106 阅读 · 0 评论 -
4.2 while range循环
# number=59# guess_flag=False## while guess_flag==False:# guess=int(input("enter an inteher:"))# if guess ==number:# guess_flag=True# elif guess <number:# print("lower")# else:# print("highter")## p...原创 2020-09-17 12:12:58 · 174 阅读 · 1 评论 -
4.1控制流if for循环
if语句if condition do somethingelif other_condition do something#if 用法如下:#===============================================================================## number=59# guess =int(input("enter an integer:"))# #这是input用法# #print("guess is:"+...原创 2020-09-17 12:12:23 · 126 阅读 · 0 评论 -
3.4函数function
def say_hi(): print("hi") say_hi()say_hi()def print_sum_two(a,b): c=a+b print(c)#没有return关键字,所以这是没有返回值的函数print_sum_two(3,6)def hello_some(str): print("hello "+str+"!") hello_some("china")hello_some("china")#有返回值的函数如下:def...原创 2020-09-16 16:19:36 · 156 阅读 · 0 评论 -
3.3字典dictionary
键(key) 对应值(value)张三 12345李四 23432上面这种数据结构就是字典dictionary#创建一个词典phone_book={"Tom":123,"Jerry":456,"Kim":789}mixed_dict={"Tom":"boy",11:23.5}print("Tom has phone number:"+str(phone_book["Tom"]))phone_book["Tom"]=99...原创 2020-09-16 16:18:55 · 118 阅读 · 0 评论 -
3.2第三天数据结构tuple与list对比学习
#创建只包含一个元素的tuplea_tuple=(2,)#元素之后加上逗号,避免产生歧义mixed_tuple=(1,2,['a','b'])print("mixed_tuple:"+str(mixed_tuple))mixed_tuple[2][0]="c"mixed_tuple[2][1]="d"print("mixed_tuple after:"+str(mixed_tuple))#tuple不可以更改,但是可以更改里面的list========================.原创 2020-09-16 16:18:24 · 73 阅读 · 0 评论 -
3.2第三天数据结构(元组)tuple学习
number_tuple=(1,3,5,7,9)string_tuple =("abc","bbc","python")mixed_tuple=("python","java",3,12)print("string_tuple"+str(string_tuple))print("mixed_tuple"+str(mixed_tuple))second_num=number_tuple[1]third_string=string_tuple[2]fourth_mixed=mixed_原创 2020-09-16 16:17:52 · 88 阅读 · 0 评论 -
3.1第三天数据结构(列表)list学习
#-*- coding:utf-8 -*-print("您好")#加上#-*- coding:utf-8 -*-使得中文可以显示print("what is you name?\nTom")#换行符号\n#创建Listnumber_list = [1,3,5,7,9]print("number_list:"+str(number_list))string_list =["abc","bbc","python"]mixed_list=["python","java",3,12].原创 2020-09-16 16:17:01 · 130 阅读 · 0 评论 -
python基本情况入门了解
1。初步了解,环境配置pythonjavaeclipsePyDev2.request和pip配置3.request的使用import osimport requestsr=requests.get("http://www.baidu.com")print(r.url)print(r.encoding)print(r.content)注意点:print(r.text)可能由于乱码格式不对所以报错 print(r.content)则能正确的显示格式输出出来一,字...原创 2020-09-16 16:14:59 · 194 阅读 · 0 评论