33 4 python中insert 的用法

2021-08-29 22:44:50 字數 634 閱讀 4580

#tk-button

#python3

from tkinter import *

er = tk()

er.title("tk-button")

er.geometry('500x400')

def printhello():

t.insert('2.1', "hello\n")

def printpress():

t.insert('1.0', "press\n")

## print(t)

## t.insert('2.0', "hello\n")

t = text()

print(t)

t.pack()

button(er, text = 'hello', command = printhello).pack(side = left)

button(er, text = 'press', command = printpress).pack(side = left)

er.mainloop()

python的insert函式中有兩個必填引數,第乙個是填充的位置,第二個是填充的內容。必須有小數點,不然報錯。一般用1.0,就是往下面一行行的寫

python 3 0 在for中使用insert

首先在python 3.0手冊中有這麼個示例 a cat window defenestrate for x in a make a slice copy of the entire list if len x 6 a.insert 0,x a defenestrate cat window def...

python中 python中的 與

這一部分首先要理解python記憶體機制,python中萬物皆物件。對於不可變物件,改變了原來的值,其別名 變數名 繫結到了新值上面,id肯定會改變 對於可變物件,操作改變了值,id肯定會變,而 是本地操作,其值原地修改 對於 號操作,可變物件和不可變物件呼叫的都是 add 操作 對於 號操作,可變...

python中否定for 在python中否定函式

有沒有一種方法可以否定乙個函式,使它返回負數。在我的函式中,我有條件句,每個條件句都讓這個 烏龜 移動。有沒有一種方法可以否定這一點,所以烏龜的每乙個動作都是否定的。我說的是 狀況 在def ttinterpret program interpret program as a tinyturtle ...