2019年10月8日 星期二

Python 'a' + 1 = 'b'

在 Python 3 實現  'a' + 1 = 'b'
a = 'a'
print(chr(ord(a)+1)) # b

參考資料 : https://stackoverflow.com/questions/12797067/how-can-i-do-a-1-b-in-python

Related Posts:

  • Python - BeautifulSoup 基本應用 (2) Navigating the tree - Going down child Tag 前一篇呼叫 Tag 底下的 subTag 是用像 class 的方式 (Tag.subTag),沒完整說明的是這個 subTag 可呼叫到的範圍並不只侷限 children Tag,而是整個 Tag 底下第一個遇到的 Tag.name == subTag。 """ html <b class="bo… Read More
  • Python - sys, os.path 常見的 module 應用 Common python module - sys sys parameter 一些常見系統參數 import sys print(sys.platform) # linux sys.argv 像 c/c++ 的 argv 一樣,可以吃從 command line 傳入的參數。 # test.py 123 456 789 print (argv) … Read More
  • Python 遞迴初學最近用 python 刷題 刷到要用 DFS 的題目,想用遞迴去寫才發現 python 沒有指標 看著討論的 python 大神寫的程式碼,發現都是 python 裡的參數都是指標 下面拿一題示範 0947 - Most Stones Removed with Same Row or Column class Solution: def removeStones(self, stones: List[L… Read More
  • Python - BeautifulSoup 基本應用 (1) BeautifulSoup 紀錄下 Python 網頁爬蟲大部分會用到的 BeautifulSoup。BeautifulSoup 本質上就是 parser,知道這點後其 function 和 parameter 的使用就能得心應手。 Install 這裡紀錄使用 pip 安裝 pip install beautifulsoup4 pip install lxml # 非必要 I… Read More
  • Python bin() Python bin() bin(10) // 0b1010 type(bin(10)) // <class 'str'> bin(10)[2:] // 1010 … Read More

0 意見:

張貼留言

Popular Posts