<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>python &#8211; 张三太爷</title>
	<atom:link href="https://www.somedoc.net/tag/python/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.somedoc.net</link>
	<description>看前面，黑洞洞</description>
	<lastBuildDate>Sat, 09 May 2020 13:53:38 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.1</generator>

<image>
	<url>https://www.somedoc.net/wp-content/uploads/2016/12/cropped-dandycheung-1-32x32.jpg</url>
	<title>python &#8211; 张三太爷</title>
	<link>https://www.somedoc.net</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Python 编程小得</title>
		<link>https://www.somedoc.net/2020/05/09/python-%e7%bc%96%e7%a8%8b%e5%b0%8f%e5%be%97/</link>
					<comments>https://www.somedoc.net/2020/05/09/python-%e7%bc%96%e7%a8%8b%e5%b0%8f%e5%be%97/#respond</comments>
		
		<dc:creator><![CDATA[张三太爷]]></dc:creator>
		<pubDate>Sat, 09 May 2020 08:51:36 +0000</pubDate>
				<category><![CDATA[技术]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[web]]></category>
		<guid isPermaLink="false">https://www.somedoc.net/?p=4475</guid>

					<description><![CDATA[1. 程序运行依赖的导入，可以用 try 来试探。 脚本在服 <a href="https://www.somedoc.net/2020/05/09/python-%e7%bc%96%e7%a8%8b%e5%b0%8f%e5%be%97/" class="more-link">[&#8230;]</a>]]></description>
										<content:encoded><![CDATA[<p>1. 程序运行依赖的导入，可以用 try 来试探。</p>
<p>脚本在服务器上运行，服务器有没有安装所需该扩展事先不知道，但又不想运行时死得难看。要解决这个问题，就可以用 try except 来捕获 import 的异常（如果愿意，可以即时去安装）：</p><pre class="crayon-plain-tag">#coding=utf-8
import os
import json
try:
    import jinja2
except:
    print 'Jinja2 not found. Installing...'
    os.system('pip install jinja2')
    print 'Done.'
    import jinja2</pre><p> </p>
<p>2. 学习了 Jinja2 模板的基本用法。</p>
<p><code>{{ }}</code> 内变量取值，<code>{% %}</code> 内流程控制；<code>if</code> 和 <code>for</code> 都用上了，输出了漂亮的报告表格，非常棒。</p>
<p>简洁入门可看：<a href="https://www.cnblogs.com/dachenzi/p/8242713.html">https://www.cnblogs.com/dachenzi/p/8242713.html</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.somedoc.net/2020/05/09/python-%e7%bc%96%e7%a8%8b%e5%b0%8f%e5%be%97/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Python 日期计算化繁为简一例</title>
		<link>https://www.somedoc.net/2020/04/09/python-%e6%97%a5%e6%9c%9f%e8%ae%a1%e7%ae%97%e5%8c%96%e7%b9%81%e4%b8%ba%e7%ae%80%e4%b8%80%e4%be%8b/</link>
					<comments>https://www.somedoc.net/2020/04/09/python-%e6%97%a5%e6%9c%9f%e8%ae%a1%e7%ae%97%e5%8c%96%e7%b9%81%e4%b8%ba%e7%ae%80%e4%b8%80%e4%be%8b/#respond</comments>
		
		<dc:creator><![CDATA[张三太爷]]></dc:creator>
		<pubDate>Thu, 09 Apr 2020 08:28:45 +0000</pubDate>
				<category><![CDATA[备忘录]]></category>
		<category><![CDATA[技术]]></category>
		<category><![CDATA[python]]></category>
		<guid isPermaLink="false">http://www.somedoc.net/?p=4425</guid>

					<description><![CDATA[看之前一个小兄弟的代码里有这么一句， [crayon-676 <a href="https://www.somedoc.net/2020/04/09/python-%e6%97%a5%e6%9c%9f%e8%ae%a1%e7%ae%97%e5%8c%96%e7%b9%81%e4%b8%ba%e7%ae%80%e4%b8%80%e4%be%8b/" class="more-link">[&#8230;]</a>]]></description>
										<content:encoded><![CDATA[<p>看之前一个小兄弟的代码里有这么一句，</p><pre class="crayon-plain-tag">day = time.strftime('%Y-%m-%d', time.strptime(str(datetime.datetime.now() + datetime.timedelta(days = -1))[:18], '%Y-%m-%d %H:%M:%S'))</pre><p>简直要把我看哭了，作为一个 Python 新手，写了如下代码来替代（尽管没有强行指定日期显示的格式）：</p><pre class="crayon-plain-tag">day = datetime.date.today() + datetime.timedelta(days = -1)</pre><p>短了点，清爽了点。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.somedoc.net/2020/04/09/python-%e6%97%a5%e6%9c%9f%e8%ae%a1%e7%ae%97%e5%8c%96%e7%b9%81%e4%b8%ba%e7%ae%80%e4%b8%80%e4%be%8b/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
