社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
私信  •  关注

Sharim Iqbal

Sharim Iqbal 最近创建的主题
Sharim Iqbal 最近回复了
3 年前
回复了 Sharim Iqbal 创建的主题 » python列表中的count函数
list_ = list(input("plase enter keyword"))

for item in list_:
    print(f"value({item}) {list_.count(item)}")

list_ = list(input("plase enter keyword"))

for item in list_:
    print(f"value({item})"+str(list_.count(item)))

3 年前
回复了 Sharim Iqbal 创建的主题 » 在Python Tkinter中为按钮设置背景色或背景不起作用

不幸的是,没有一种简单的方法可以从ttk库中更改按钮的背景。

但是,你可以很容易地得到你想要的一个普通tkinter。按钮,如果您设置了正确的选项。下面是一个示例脚本:

from tkinter import *
from tkinter import ttk

root = Tk()
frame = Frame(root).grid(row = 0, column = 0)

button = Button(frame, text = "CLICK ME", bg = '#05752a').grid(row = 0, column = 0)

root.mainloop()

这是另一个的链接 post

3 年前
回复了 Sharim Iqbal 创建的主题 » 在Python中,可以将列表中的元素添加到字典的值中吗?

我知道有更多的方法可以做到这一点,但我认为这是更具可读性和可理解性的代码。

list_of_lists = [[966], [1513, 2410], [2964, 1520, 604]] 

dict_ = {'Youngstown': ['OH', 4110, 8065, 115436], 'Yankton': ['SD', 4288, 9739, 
12011], 'Yakima': ['WA', 4660, 12051, 49826]}

i = 0
# list(dict_.items())[1:] is the list of all keys and values except first one.
for key,value in list(dict_.items())[1:]:
    dict_[key] = value+[list_of_lists[i]]
    i+=1
print(dict_)

3 年前
回复了 Sharim Iqbal 创建的主题 » Python:仅当总和不为零时打印

n , m = map(int, input().split()) 
num_list = list(map(int,input().split()))

mult_list=[]
non_mult_list=[]
if m >= 2 and m <= 9:
    for i in (num_list)[:n]:
        if i%m == 0:
            mult_list.append(i)
        
    for j in (num_list)[:n]:
        if j%m != 0:
            non_mult_list.append(j)
sum_mult_list = sum(mult_list)
sum_non_mult_list = sum(non_mult_list)
if sum_mult_list: # edited
    print(sum_mult_list)
if sum_non_mult_list: #edited
    print(sum_non_mult_list)
3 年前
回复了 Sharim Iqbal 创建的主题 » 如何在python中读取文本文件,然后在同一个文件中写入内容

这段代码可能会对你有所帮助。

with open('result.txt','r') as file:
    data = file.readlines() # return list of all the lines in the text file.

for a in range(len(data)): # loop through all the lines.
    if 'person' in data[a] and 'tv' in data[a]: # Check if person and tv in the same line.
        data[a] = data[a].replace('\n','') + ' status : High\n'
    elif 'person' in data[a] and 'laptop' in data[a]:# Check if person and laptop in the same line.
        data[a] = data[a] + ' status : Low\n'

with open('result.txt','w') as file: 
    file.writelines(data) # write lines to the file.