Python QlistWidget Questions

Asked 2 weeks ago, Updated 2 weeks ago, 1 views

Hello, I looked up a lot through Google, but I don't know, so I'm posting a question

        with open("text.txt", "r",encoding='UTF8') as tf:
            lines = tf.read().split(',')
        for line in lines:
            self.listWidget.addItem(line)

The text file is saved as above

It is indicated as below.

What I want to do is The order on that list too? I think he's there I'd like to bring the text in each order.

For example,

print(listwidgetnum1) <<< file 
print(listwidgetnum2) <<< Clear File 
print(listwidgetnum3) <<< pp file 

In this way, I want to get the text in the list widget just in the order. Thank you very much for your reply.

python qt-designer

2022-09-20 11:05

1 Answers

The list index must be used.

It's good to try to find it, but before that, it's very helpful to study Python basic grammar first.

After experiencing it, it was very difficult because there was no foundation like this even if I tried to find what I needed.

Of course, I'm still lacking a lot of basics because I'm self-taught. Haha;;

list = [2, 3, 4, 5, 6, 7]

value = 2 3 4 5 6 7
index = 0 1 2 3 4 5 

If you want to get 6 from the list?
a = list[4]
print(a)
>> 6


2022-09-20 11:05

If you have any answers or tips


© 2022 pinfo. All rights reserved.