<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Python on Wenhan blog</title>
    <link>https://wenhan.blog/en/tags/python/</link>
    <description>Recent content in Python on Wenhan blog</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-US</language>
    <lastBuildDate>Tue, 05 Sep 2017 10:30:55 +0000</lastBuildDate><atom:link href="https://wenhan.blog/en/tags/python/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>systemctl command return &#39;Failed to connect to bus: No such file or directory&#39; in a docker container</title>
      <link>https://wenhan.blog/en/posts/20170905_systemctl-command-return-failed-to-connect-to-bus-no-such-file-or-directory-in-a-docker-container/</link>
      <pubDate>Tue, 05 Sep 2017 10:30:55 +0000</pubDate>
      
      <guid>https://wenhan.blog/en/posts/20170905_systemctl-command-return-failed-to-connect-to-bus-no-such-file-or-directory-in-a-docker-container/</guid>
      <description>To enable and start a cron job and a httpd server in a docker container, I tried systemctl command but get an error output like this
1 2 3 4 [root@5f1f0a5cde43 app]# systemctl status crond Failed to connect to bus: No such file or directory [root@5f1f0a5cde43 app]# systemctl status httpd Failed to connect to bus: No such file or directory Fix this issue by add --privileged parameter to docker run command</description>
    </item>
    
    <item>
      <title>Desktop Notifier by Python</title>
      <link>https://wenhan.blog/en/posts/20170728_desktop-notifier-by-python/</link>
      <pubDate>Fri, 28 Jul 2017 16:37:40 +0000</pubDate>
      
      <guid>https://wenhan.blog/en/posts/20170728_desktop-notifier-by-python/</guid>
      <description>This article show how to send desktop notice using Python
Install requirments we need to install notify2 by pip
1 2 3 4 5 $ pip install notify2 Collecting notify2 Downloading notify2-0.3.1-py2.py3-none-any.whl Installing collected packages: notify2 Successfully installed notify2-0.3.1 Coding First we need to import notify2
1 import notify2 Then need to initialise the d-bus connection. D-Bus is a message bus system, a simple way for applications to talk to one another.</description>
    </item>
    
    <item>
      <title>Get Daily Weather Info and Send by Gmail with Python</title>
      <link>https://wenhan.blog/en/posts/20170421_get-weather-info-and-send-by-gmail-python/</link>
      <pubDate>Fri, 21 Apr 2017 00:16:17 +0000</pubDate>
      
      <guid>https://wenhan.blog/en/posts/20170421_get-weather-info-and-send-by-gmail-python/</guid>
      <description>After being caught in the rain several times for not checking the weather forecast, I decided to write a small program for lazy people like me. It&amp;rsquo;s simple, just a small Python exercise: use Python to send daily weather reminders by email.
This program is divided into two steps:
Get weather information from a website Send the weather information to a specified mailbox by email Getting Weather Information Here I used the popular requests and BeautifulSoup4 libraries to fetch and extract information from a webpage.</description>
    </item>
    
    <item>
      <title>Creating a Spider with Python</title>
      <link>https://wenhan.blog/en/posts/20161201_crawling-webpage-use-python-requests/</link>
      <pubDate>Thu, 01 Dec 2016 00:54:09 +0000</pubDate>
      
      <guid>https://wenhan.blog/en/posts/20161201_crawling-webpage-use-python-requests/</guid>
      <description>Using Python&amp;rsquo;s Requests library, you can extract and save the contents of a web page. Then, by using the BeautifulSoup library, you can extract the information you want.
What is Requests? Requests is a Python HTTP library that is much easier to use than urllib2. As described on the official site:
Requests is an Apache2 Licensed HTTP library, written in Python, for human beings.
As the description says, it allows you to write code that is easy for humans to read.</description>
    </item>
    
    <item>
      <title>Using Google Maps API with Python</title>
      <link>https://wenhan.blog/en/posts/20161112_google-maps-api-with-python/</link>
      <pubDate>Sat, 12 Nov 2016 01:22:46 +0000</pubDate>
      
      <guid>https://wenhan.blog/en/posts/20161112_google-maps-api-with-python/</guid>
      <description>I tried using the Google Maps API in Python to perform route search.
The module used is googlemaps/google-maps-services-python
You can set up the environment with the following commands. While you&amp;rsquo;re at it, also install ipython.
1 2 pip install googlemaps pip install ipython You also need to apply for a Google API key, so go to Google APIs to apply and enable it.
If everything is fine up to this point, let&amp;rsquo;s try it out right away.</description>
    </item>
    
    <item>
      <title>Checking Palindromes in Python</title>
      <link>https://wenhan.blog/en/posts/20161029_python-reverse-str-to-check-palindrome/</link>
      <pubDate>Sat, 29 Oct 2016 01:21:18 +0000</pubDate>
      
      <guid>https://wenhan.blog/en/posts/20161029_python-reverse-str-to-check-palindrome/</guid>
      <description>I solved another problem: Palindrome chain length
This is a calculation problem about palindromes. A palindrome is a string that, when split in the middle, has left and right sides that are symmetric in reverse order. For example, &amp;ldquo;あいういあ&amp;rdquo; is a palindrome, while &amp;ldquo;あいうえお&amp;rdquo; is not. The same applies to numbers: 5, 44, 171, 4884 are palindromes, while 43, 194, 4773 are not.
This problem asks, for a given number, how many times a specific calculation must be performed to make it a palindrome.</description>
    </item>
    
    <item>
      <title>Python Output Formatting</title>
      <link>https://wenhan.blog/en/posts/20161029_python-print-format/</link>
      <pubDate>Sat, 29 Oct 2016 00:28:06 +0000</pubDate>
      
      <guid>https://wenhan.blog/en/posts/20161029_python-print-format/</guid>
      <description>I practiced another CodeWar problem today: RGB To Hex Conversion
To put it simply, the problem is to convert RGB numbers to hexadecimal and output them.
1 2 3 4 rgb(255, 255, 255) # returns FFFFFF rgb(255, 255, 300) # returns FFFFFF rgb(0,0,0) # returns 000000 rgb(148, 0, 211) # returns 9400D3 If you convert directly with hex, you get an extra &amp;ldquo;0x&amp;rdquo; and &amp;ldquo;00&amp;rdquo; becomes &amp;ldquo;0&amp;rdquo;. I wondered if there was a function like sprintf, and found this site: String formatting like C&amp;rsquo;s sprintf</description>
    </item>
    
  </channel>
</rss>
