我是Python的新手,我试图做以下事情.
在PHP中,如果我们想转换日期,我们使用这样的东西:
$item_date = date("Y-m-j G:i:s", strtotime($RSSitem->pubDate));
Run Code Online (Sandbox Code Playgroud)
现在,我试图使用Python做同样的事情,但我无法理解这样做的确切方法.
任何人都可以通过将此行写入python来帮助我吗?
我有以下元组:
['Southampton', '9', '14', '13']
['Nottingham Forest', '8', '10', '17']
['Coventry City', '7', '4', '14']
['Blackburn Rovers', '4', '6', '14']
['Newcastle United', '24', '20', '10']
['FC Wimbledon', '21', '20', '11']
['Arsenal', '21', '19', '8']
Run Code Online (Sandbox Code Playgroud)
我想按第2和第3列排序.所以我使用以下代码:
sorted_rank = sorted(temp_rank, key=itemgetter(1,2), reverse=True)
Run Code Online (Sandbox Code Playgroud)
但正如您所看到的那样,第2列和第3列不是int,因此排序过程完成错误.我如何"告诉"python这些列是int而不是字符串?
我尝试了这个,但没有:
sorted_rank = sorted(temp_rank, key=itemgetter(1,int(2)), reverse=True)
Run Code Online (Sandbox Code Playgroud) MySQL查询最多返回65535行(最大值).如何检索超过限制的表的所有行?(总共120k)
query_string1 = "SELECT DISTINCT ID FROM table1"
print query_string1
try:
self.cursor.execute(query_string1)
self.ids = self.cursor.fetchall()
print "Select query was successfully executed"
print "%d unique ids where retrieved" %len(self.ids)
Run Code Online (Sandbox Code Playgroud)