Python! Are you kidding me ?, Pythonkidding

Source: Internet
Author: User

Python! Are you kidding me ?, Pythonkidding

A few days ago, I was excited by python and wrote an article called The beauty of python 1. Today, I wrote this article due to a small mistake.

The problem is also caused by my work:

I have a document that stores a line of information.

Item category # number of items in this category

The product category does not appear # (so I used # As the separator when saving it), and the product is always numbered from 1 to n. After I get the number of the product, you can traverse and call the operation function (simply record it as fun ).

Naturally, I set the delimiter to use split. Then I wrote a few lines of such code.

f=open('record.txt','r')info=f.readlines()[0]f.close()end=info.split('#')[-1]beg=1while beg<=end:       fun(beg)       beg+=1
Then I handed it over to the background with peace of mind.

nohup python a.py &

I was writing something else later, because it was processing massive data, so I waited for another afternoon to go back and see that the program was not over, and it was no longer within my expectation.

Smart, do you see any problems?

Then I added a simple sentence.

F=open('record.txt ', 'R') info = f. readlines () [0] f. close () end = info. split ('#') [-1] beg = 1 while beg <= end: print beg # This sentence fun (beg) beg + = 1

However, I have a large amount of data and the fun operation time is very slow! This is tangled! So simple results can lead to errors? I have no doubt about the main function, but I went to see the fun section, but I tried it many times, but I still can't do it.

At that time, I almost suspected that my py was broken and was still teasing me! (The author is anxious to doubt his compiler! My fun is a bunch of disgusting regular expressions)

Later, I observed it with the naked eye. Is there a problem with my split? Then I added another sentence.

F=open('record.txt ', 'R') info = f. readlines () [0] f. close () end = info. split ('#') [-1] print end # This sentence beg = 1 while beg <= end: print beg fun (beg) beg + = 1
End is still normal! Now I am worried. Is it my program problem or is it really not running?

Then, I went to the bathroom.

Think twice, as if the string is obtained after split !! String!

However, isn't a string converted to a number? Then it won't end up, for example, '18' (I suppose it's all about, but most of it is actually done .)

What is the comparison between numbers and strings?

Then I wrote a test function.

beg=1while beg<'1':    print beg    beg+=1

An endless loop...

I changed the program with anger and excitement.

f=open('record.txt','r')info=f.readlines()[0]f.close()end=int(info.split('#')[-1])beg=1while beg<=end:       fun(beg)       beg+=1


The program is finally normal.

Okay. It's been played by py for an afternoon.

Later, I found that an error will be reported directly when xrange is used. Next time, use xrange.





Are you kidding me? What is it?

Are you kidding me?
In general, this is a joke!
For example:
A: can you give me all your money?
B: are you kidding me?

Are you fucking kidding me?

Is this translation?
Turning it into "are you playing with me ?!!"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.