[Solved] Tkinter, try to keep using the program on while executing

You can use root.after(miliseconds, function_name, argument) to execute function with delay and root.mainloop() (and program) will work normally. You can use datetime to convert text to datetime object, substract two dates and get difference in milliseconds. try: import tkinter as tk import tkinter.messagebox as tkMessageBox print(“Python 3”) except: import Tkinter as tk import tkMessageBox print(“Python … Read more

[Solved] How to delete text form txt file using python

You could do it like this: input_file = open(‘filename.txt’) output_file = open(‘output_filename.txt’, ‘w’) for line in input_file.readlines()[1:]: output_file.write(line + ‘\n’) output_file.close() Same thing using single file: input_file = open(‘filename.txt’) input_data = [line for line in input_file.readlines()] input_file.close() output_file = open(‘filename.txt’, ‘w’) for line in input_data[1:]: output_file.write(line + ‘\n’) output_file.close() 2 solved How to delete text … Read more

[Solved] Python Label Printer Program

here is something to get you started, but I doubt it is complete. You will need to provide a valid ZPL file for making the changes. I also made the program use fixed numbers for now and so it just runs and outputs.You can change it back once you have it working. start = 110 … Read more

[Solved] IndentationError: unindent does not match any outer indentation level I do not understand anything [closed]

I diagrammed your code. See how the line that’s throwing an error doesn’t line up with any previous indentations? Python doesn’t know what to do with that, so it throws an error. In general, try and make your indentations always the same number of spaces, to avoid this. Consider these two pieces of code: a … Read more

[Solved] How to split a string without given delimeter in Panda

Assuming your split criteria is by fixed number of characters (e.g. 5 here), you can use: df[‘dfnewcolumn1’] = df[‘dfcolumn’].str[:5] df[‘dfnewcolumn2’] = df[‘dfcolumn’].str[5:] Result: dfcolumn dfnewcolumn1 dfnewcolumn2 0 PUEF2CarmenXFc034DpEd PUEF2 CarmenXFc034DpEd 1 PUEF2BalulanFc034CamH PUEF2 BalulanFc034CamH 2 CARF1BalulanFc013Baca CARF1 BalulanFc013Baca If your split criteria is by the first digit in the string, you can use: df[[‘dfnewcolumn1’, ‘dfnewcolumnX’]] … Read more

[Solved] date_range generator last 30 days Python [closed]

You should create an empty list and keep appending the dates: import datetime def date_range(): result = [] current = datetime.date(2021, 3, 1) end = datetime.date(2021, 3, 31) delta = datetime.timedelta(days=1) while current <= end: result.append(current) current += delta return result print(date_range()) Of course, you can pass start and end as parameters, which makes much … Read more

[Solved] Python convert list to dict with multiple key value [closed]

Several ways to do this, this is one: EDIT: my first solution gave a list for every value, but you only require a list when there is more than one value for a key. my_list = [‘key1=value1’, ‘key2=value2’, ‘key3=value3-1’, ‘value3-2’, ‘value3-3’, ‘key4=value4’, ‘key5=value5’, ‘value5-1’, ‘value5-2’, ‘key6=value6’] my_dict = {} current_key = None for item in … Read more

[Solved] Python declare multiple lists

You can use a dictionary to store the values: x=[‘aze’,’qsd’,’frz’,…] vars = {} for i in x: vars[“MAX” + i] = [] Or in order for them to become real variables you can add them to globals: x=[‘aze’,’qsd’,’frz’,…] for i in x: globals()[“MAX” + i] = [] You can now use: MAXaze = [1,2,3] 3 … Read more