In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Python editing skills, for this problem, this article details the corresponding analysis and solutions, hoping to help more friends who want to solve this problem to find a simpler and easier way.
For users and scholars who have come into contact with Python editing many times, it is very important to understand the concept of Python, so let's first say what Python editing is, the so-called Python language: it is a very widely used computer programming language.
As the name suggests, PIL (Python Imaging Library) is based on Python editing, so I downloaded Python 2.6 from the day before yesterday and read Python concise manual. In this manual, the author recommends beginners to do such a program, that is, to create your own command-line address book program.
In this program, you can add, modify, delete, and search your contacts (friends, family, colleagues, etc.) and their information (such as email addresses and/or phone numbers). These details should be saved for later retrieval.
#!/ usr/bin/env python # -*- coding: GBK -*- import urllib from sgmllib import SGMLParser class URLLister(SGMLParser): def reset(self): SGMLParser.reset(self) self.urls = [] def start_a(self, attrs): href = [v for k, v in attrs if k == 'href'] if href: self.urls.extend(href) url = r'http://www.sinc.sunysb.edu/Clubs/buddhism/JinGangJingShuoShenMo/' sock = urllib.urlopen(url) htmlSource = sock.read() sock.close() #print htmlSource f = file('jingangjing.html', 'w') f.write(htmlSource) f.close() mypath = r'http://www.sinc.sunysb.edu/Clubs/buddhism/JinGangJingShuoShenMo/' parser = URLLister() parser.feed(htmlSource) for url in parser.urls: myurl = mypath + url print "get: " + myurl sock2 = urllib.urlopen(myurl) html2 = sock2.read() sock2.close() #Save to File print "save as: " + url f2 = file(url, 'w') f2.write(html2) f2.close()
I guess there are some basic things that are not used well, there must be a simpler way. In fact, it is used to practice, I do not have too much expectation to do well, the program runs after the request to enter a project directory path, the results generated in D disk under the log.html file.
In addition to python's own PIL package, you can also use ImageMagic, so that Gimp can do what python can do, write 10 lines of programs, can handle a large number of images, such pleasure is not much. Three years ago, I helped a JJ write a program to process satellite images, roughly cutting satellite cloud images into 32*32 squares, calculating threshold values in turn and then counting them.
I used all afternoon for a week, pure c, almost 1500 lines of code, at that time is in love, IQ is relatively low, in windows above, install a gcc, editplus editor, gdb+printf to debug, although *** small sense of achievement, it took a lot of effort, the core part of the program, if you use Python editor to do, just a few lines to get it.
Down some articles from the Internet, need to delete the blank lines inside; there is no rule of large numbers, need to sum; different formats of header file conversion, etc.; this is better handled with perl, 3 years ago I did the same, when I met python, I completely gave up perl.
Perl is very good, basically the same function, write code with python will grow some, the network community provides a variety of perl function package is also more, but Larry Wall is a poet, poet temperament let perl syntax, in our eyes these programmers look very messy.
Basically not used for 2 weeks, to get perl work, you have to find a grammar book to read again. Under linux is fine, you can man a handful, if you install an ActivePerl on windows, you have to open the html file Perl Core Documentation for help.
Line by line, although the help system of scripting language can not be compared with the help of commercial development tools such as. Net, Java, etc., Python has at least a chm file that can be indexed. Perl is for real hackers, simplicity and clarity are Python's strengths. As a professional network administrator, perl is the right choice. As for ordinary programmers 'toys, python is better.
About Python editing skills what questions are shared here, I hope the above content can be of some help to everyone, if you still have a lot of doubts not solved, you can pay attention to the industry information channel to learn more related knowledge.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 290
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.